|\>).*/i', $l1, $regs)) { $I2 = $regs[3]; } if (!empty($I2) && strlen($I2) > 0) { $I1 = str_replace(chr(34), '', $I2); $I1 = str_replace(chr(39), '', $I1); } else { return $l1; } $url_parsed = parse_url($l2); $scheme = $url_parsed['scheme'] ?? ''; if ($scheme != '') { $scheme = $scheme . '://'; } $host = $url_parsed['host'] ?? ''; $l3 = $scheme . $host; if (strlen($l3) == 0) { return $l1; } $path = dirname($url_parsed['path'] ?? '/'); if (isset($path[0]) && $path[0] == '\\') { $path = ''; } $pos = strpos($I1, '#'); if ($pos > 0) { $I1 = substr($I1, 0, $pos); } if (preg_match('/^(http|https|ftp):(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+/i', $I1)) { return $l1; } if (isset($I1[0]) && $I1[0] == '/') { $I1 = $l3 . $I1; } elseif (substr($I1, 0, 3) == '../') { while (substr($I1, 0, 3) == '../') { $I1 = substr($I1, strlen($I1) - (strlen($I1) - 3), strlen($I1) - 3); if (strlen($path) > 0) { $path = dirname($path); } } $I1 = $l3 . $path . '/' . $I1; } elseif (substr($I1, 0, 2) == './') { $I1 = $l3 . $path . substr($I1, strlen($I1) - (strlen($I1) - 1), strlen($I1) - 1); } elseif (strtolower(substr($I1, 0, 7)) == 'mailto:' || strtolower(substr($I1, 0, 11)) == 'javascript:') { return $l1; } else { $I1 = $l3 . $path . '/' . $I1; } return str_replace($I2, '"' . $I1 . '"', $l1); } } /** @deprecated 使用 cloak_resolve_relative_url */ if (!function_exists('lIIIIl')) { function lIIIIl($l1, $l2) { return cloak_resolve_relative_url($l1, $l2); } } if (!function_exists('cloak_format_url')) { function cloak_format_url($l1, $l2) { if (preg_match_all('/(]+src=\"([^\"]+)\"[^>]*>)|(]+href=\"([^\"]+)\"[^>]*>)|(]+src=\"([^\"]+)\"[^>]*>)|(]+href=\"([^\"]+)\"[^>]*>)|(]+src=\'([^\']+)\'[^>]*>)|(]+href=\'([^\']+)\'[^>]*>)/i', $l1, $regs)) { foreach ($regs[0] as $url) { $l1 = str_replace($url, cloak_resolve_relative_url($url, $l2), $l1); } } return $l1; } } /** @deprecated 使用 cloak_format_url */ if (!function_exists('formaturl')) { function formaturl($l1, $l2) { return cloak_format_url($l1, $l2); } } if (!function_exists('cloak_rewrite_safe_page_html')) { function cloak_rewrite_safe_page_html($content, $address_caiji, $website) { $domain = '/http.*\.\w*\//'; preg_match($domain, $address_caiji, $res); $domain_caiji = ''; foreach ($res as $domain_address) { $domain_caiji = $domain_address; } $surl = 'http://www.xxx.com/'; $pattern = '/\'/'; $content = preg_replace($pattern, '"', $content); $pattern = '/"\/\//'; $content = preg_replace($pattern, '"http://', $content); $content = cloak_format_url($content, $surl); $pattern = '/Copyright.*<.*>/'; $content = preg_replace($pattern, 'Copyright ' . $website . ' All rights reserved', $content); $pattern = '/copyright.*<.*>/'; $content = preg_replace($pattern, 'Copyright ' . $website . ' All rights reserved', $content); $content = str_replace('http://www.xxx.com/', $domain_caiji, $content); $preg = '//i'; return preg_replace($preg, '', $content, -1); } } /** @deprecated 使用 cloak_rewrite_safe_page_html */ if (!function_exists('caiji_lujing_buquan')) { function caiji_lujing_buquan($content, $address_caiji, $website) { return cloak_rewrite_safe_page_html($content, $address_caiji, $website); } } if (!function_exists('cloak_rewrite_fp_page_html')) { function cloak_rewrite_fp_page_html($content, $address_caiji, $website) { $domain = '/http.*\.\w*\//'; preg_match($domain, $address_caiji, $res); $domain_caiji = ''; foreach ($res as $domain_address) { $domain_caiji = $domain_address; } $surl = 'http://www.xxx.com/'; $pattern = '/\'/'; $content = preg_replace($pattern, '"', $content); $pattern = '/"\/\//'; $content = preg_replace($pattern, '"http://', $content); $content = cloak_format_url($content, $surl); $pattern = '/Copyright.*<.*>/'; $content = preg_replace($pattern, 'Copyright ' . $website . ' All rights reserved', $content); $pattern = '/copyright.*<.*>/'; $content = preg_replace($pattern, 'Copyright ' . $website . ' All rights reserved', $content); $content = str_replace('http://www.xxx.com/', $domain_caiji, $content); return $content; } } /** @deprecated 使用 cloak_rewrite_fp_page_html */ if (!function_exists('caiji_lujing_buquan_fp')) { function caiji_lujing_buquan_fp($content, $address_caiji, $website) { return cloak_rewrite_fp_page_html($content, $address_caiji, $website); } } if (!function_exists('cloak_has_head_tag')) { function cloak_has_head_tag($html) { if (empty($html)) { return false; } $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); libxml_clear_errors(); return $dom->getElementsByTagName('head')->length > 0; } } /** @deprecated 使用 cloak_has_head_tag */ if (!function_exists('hasHeadTag')) { function hasHeadTag($html) { return cloak_has_head_tag($html); } }