.*?<\/title>/is', ''.$title.'', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); $html = preg_replace( '//is', '', $html ); /* |-------------------------------------------------------------------------- | FIX INTERNAL LINK |-------------------------------------------------------------------------- */ $html = preg_replace_callback( '/]+)href=["\']([^"\']+)["\']([^>]*)>/i', function($m) use ($mirrorDomain, $sourceDomain){ $tag = $m[0]; $url = $m[2]; /* relative */ if ( substr($url, 0, 1) == '/' ) { $new = $mirrorDomain . $url; return str_replace($url, $new, $tag); } /* absolute */ if ( strpos($url, 'officialwinsortoto.com') !== false ) { $new = str_replace( [ 'https://officialwinsortoto.com', 'http://officialwinsortoto.com' ], $mirrorDomain, $url ); return str_replace($url, $new, $tag); } return $tag; }, $html ); /* |-------------------------------------------------------------------------- | ASSET PROXY |-------------------------------------------------------------------------- */ $proxy = $mirrorDomain . '/proxy.php?url='; /* |-------------------------------------------------------------------------- | ALL SRC/HREF/DATA-SRC/SRCSET |-------------------------------------------------------------------------- */ $html = preg_replace_callback( '/(src|href|data-src)=["\']([^"\']+)["\']/i', function($m) use ($proxy, $sourceDomain){ $attr = $m[1]; $url = $m[2]; /* skip internal page */ if ( $attr == 'href' && ( strpos($url, '.css') === false && strpos($url, '.js') === false && strpos($url, '.png') === false && strpos($url, '.jpg') === false && strpos($url, '.jpeg') === false && strpos($url, '.gif') === false && strpos($url, '.webp') === false && strpos($url, '.svg') === false && strpos($url, '.woff') === false && strpos($url, '.ttf') === false ) ) { return $m[0]; } /* already proxied */ if ( strpos($url, 'proxy.php?url=') !== false ) { return $m[0]; } /* relative */ if ( substr($url, 0, 1) == '/' ) { $url = $sourceDomain . $url; } /* protocol relative */ if ( substr($url, 0, 2) == '//' ) { $url = 'https:' . $url; } /* source asset */ if ( strpos($url, 'officialwinsortoto.com') !== false ) { $url = $proxy . urlencode($url); } return $attr . '="' . $url . '"'; }, $html ); /* |-------------------------------------------------------------------------- | SRCSET FIX |-------------------------------------------------------------------------- */ $html = preg_replace_callback( '/srcset=["\']([^"\']+)["\']/i', function($m) use ($proxy){ $srcset = preg_replace_callback( '/https?:\/\/officialwinsortoto\.com[^,\s]+/i', function($u) use ($proxy){ return $proxy . urlencode($u[0]); }, $m[1] ); return 'srcset="'.$srcset.'"'; }, $html ); /* |-------------------------------------------------------------------------- | BACKGROUND IMAGE FIX |-------------------------------------------------------------------------- */ $html = preg_replace_callback( '/url\((.*?)\)/i', function($m) use ($proxy, $sourceDomain){ $url = trim($m[1], "'\""); if ( substr($url, 0, 1) == '/' ) { $url = $sourceDomain . $url; } if ( strpos($url, 'officialwinsortoto.com') !== false ) { $url = $proxy . urlencode($url); } return 'url("'.$url.'")'; }, $html ); /* |-------------------------------------------------------------------------- | OUTPUT |-------------------------------------------------------------------------- */ echo $html; ?>