Este es el codigo completo, para que os hagais una idea:
Código PHP:
<?php
function extension($archivo){
$posicion = strrpos($archivo,'.')+1;
$extension = substr($archivo,$posicion);
return $extension;
}
if ($_GET['url2']) {
$url = base64_encode($_GET['url2']);
if (extension($_GET['url2']) == "css") {
header('Content-type: css-stylesheet');
echo file_get_contents("http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url=$url");
} else {
echo "<script>window.location='web.php?url=$url';</script>";
}
exit;
}
if ($_GET['url']) {
$url_b6 = base64_decode("$_GET[url]");
$url = md5($_GET['url']);
$ch = curl_init ("$url_b6");
$fp = fopen ("".$url.".html", "w");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
$ff = file_get_contents("".$url.".html");
$exp1 = explode('href="', $ff);
$c_explode = count($exp1);
for($i=1;$i<=$c_explode;$i++) {
$exp2 = explode('"', $exp1[$i]);
if (strstr($exp2[0], 'http://')) {
$ff = str_ireplace("href='http://", "href='http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
$ff = str_ireplace('href="http://', "href=\"http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
} else {
$ff = str_ireplace("href='", "href='http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
$ff = str_ireplace('href="', "href=\"http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
}
}
echo $ff;
unlink("".$url.".html");
exit;
}
?><form method="GET" target="url" action="<?=$_SERVER[PHP_SELF]?>">
<p>URL<input type="text" name="url2" size="88" onclick="this.value='http://www.';" value="http://www.example.com"></p>
<p><input type="submit" value="Enviar" name="send"><input type="reset" value="Restablecer" name="B2"></p>
</form>
<p>
<iframe name="url" width="100%" height="100%" style="border: 1px dotted #C0C0C0">
</iframe></p>
Para eso he creado este codigo
Código PHP:
$exp1 = explode('href="', $ff);
$c_explode = count($exp1);
for($i=1;$i<=$c_explode;$i++) {
$exp2 = explode('"', $exp1[$i]);
if (strstr($exp2[0], 'http://')) {
$ff = str_ireplace("href='http://", "href='http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
$ff = str_ireplace('href="http://', "href=\"http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
} else {
$ff = str_ireplace("href='", "href='http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
$ff = str_ireplace('href="', "href=\"http://$_SERVER[SERVER_NAME]".$folder."".$_SERVER[PHP_SELF]."?url2=http://", $exp2[0]);
}
}
Alguien me podria dar un consejo?
Gracias y un saludo!