<?php
function file_get_contents_curl($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       

    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}
//Get the raw html.
$furl=trim($_GET["furl"]);
$furl = str_replace('ANDTHISISJUSTJOKESOCOMEON','&',$furl);
$furl = str_replace('QUESTIONSYMBOLRIGHTHERE','?',$furl);
$raw = file_get_contents($furl);
if(empty($raw)) {
	$raw = file_get_contents_curl($furl);
}


//Kill anoying popups.
$raw=str_replace("alert(","isNull(",$raw);
$raw=str_replace("window.open","isNull",$raw);
$raw=str_replace("prompt(","isNull(",$raw);
$raw=str_replace("mTop = top;","",$raw);
$raw=str_replace("mSelf = self;","",$raw);
$raw=str_replace('").submit();','")',$raw);

if(!preg_match("decode(", $raw)){

//Kill anoying popups.
$raw=str_replace("alert(","isNull(",$raw);
$raw=str_replace("window.open","isNull",$raw);
$raw=str_replace("window.top.location","isNull",$raw);
$raw=str_replace("window.onbeforeunload","isNull",$raw);
$raw=str_replace("top.location.href","isNull",$raw);
$raw=str_replace("top.location","isNull",$raw);
$raw=str_replace("prompt(","isNull(",$raw);
$raw=str_replace("Confirm: (","isNull(",$raw);

}

//Or kill js files
//$raw=str_replace(".js",".off",$raw);

//Put in a base domain tag so images, flash and css are certain to work.
$replacethis="<head>";
$replacestring="<head><base href='".$furl."/'>";
$raw=str_replace($replacethis,$replacestring,$raw);

$rawc = $raw;
$rawc = preg_replace('/\s+/', '', $rawc);
//Echo the website html to the iframe.
if (strpos($rawc,'<body></body>') !== false) {
?>
<div id="notloaded" style="background: none repeat scroll 0% 0% rgb(255, 255, 255); color: rgb(0, 0, 0); padding: 0px; padding-top: 40px; height: 100%; width: 100%;">
	<p style="margin-top: 100px;">
		<center>
			<h1 id="loadtext"> Link could not be loaded<br></h1> <h3>Potential problems:</h3> <br> <h4>1. Requested link could not be reachable. <br> 2. Website contains scripts that would to redirect you out from this window.</h4>
			<br><br><br><br><br><br><small>#1</small>
		</center>
	</p>
</div>
<?php
}else if (empty($rawc)) {
?>
<div id="notloaded" style="background: none repeat scroll 0% 0% rgb(255, 255, 255); color: rgb(0, 0, 0); padding: 0px; padding-top: 40px; height: 100%; width: 100%;">
	<p style="margin-top: 100px;">
		<center>
			<h1 id="loadtext"> Link could not be loaded<br></h1> <h3>Potential problems:</h3> <br> <h4>1. Requested link could not be reachable. <br> 2. Website contains scripts that would to redirect you out from this window.</h4>
			<br><br><br><br><br><br><small>#2</small>
		</center>
	</p>
</div>
<?php
}else{
	echo $raw;
}

?>