09-11-2006, 11:07 AM
| THREAD STARTER
#1 (permalink)
|
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
| Need a bit of help (eregi_replace not working) DEMO: http://mikor.clearlyhosted.org/proxy...www.google.com
If you view the source (or hover over the links) the target path hasnt been changed properly... heres the code: PHP Code: <?php
$page = $_GET['p'];
$ext = substr(strrchr($url, "."), 1);
$contents = file_get_contents($page);
$exts['html'] = array("htm","html","shtml","php","php3","php4","php5","phtml");
$exts['application'] = array("zip","rar","ext");
$exts['image'] = array("bmp","jpg","jpeg","gif","png","jp2");
????: NamePros.com http://www.namepros.com/programming/236894-need-bit-help-eregi_replace-not-working.html $exts['video'] = array("mov","wmv","avi","asf","rm","mpg","mp4","mpeg");
$exts['audio'] = array("mp3","wma","wmp","ogg","midi","mid","aiff");
if(in_array($ext,$exts['html'])){
header("Content-type: text/html");
FixHTML($contents);
}elseif(in_array($ext,$exts['application'])){
header("Content-type: application/".$ext);
EchoItIt($contents);
}elseif(in_array($ext,$exts['image'])){
header("Content-type: image/".$ext);
EchoIt($contents);
}elseif(in_array($ext,$exts['video'])){
header("Content-type: video/".$ext);
EchoIt($contents);
}elseif(in_array($ext,$exts['audio'])){
header("Content-type: audio/".$ext);
EchoIt($contents);
}else{
if(eregi('<html>',$contents)){
header("Content-type: text/html");
FixHTML($contents);
}else{
header("Content-type: text/plain");
EchoIt($contents);
}
}
function FixHTML($text){
//Vars
$parts = parse_url($_GET['p']);
$uri = $parts['scheme'] . '://' .$parts['host'] . $parts['path'];
????: NamePros.com http://www.namepros.com/showthread.php?t=236894 //Absoloute URIs (href)
$text2 = str_replace('href = "http://','href = "http://mikor.clearlyhosted.org/proxy.php?p=',$text);
$text2 = str_replace('href= "http://','href = "http://mikor.clearlyhosted.org/proxy.php?p=',$text2);
$text2 = str_replace('href ="http://','href = "http://mikor.clearlyhosted.org/proxy.php?p=',$text2);
$text2 = str_replace('href="http://','href = "http://mikor.clearlyhosted.org/proxy.php?p=',$text2);
//Relative URIs (href)
$text2 = str_replace('href = "/','href = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
$text2 = str_replace('href= "/','href = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
$text2 = str_replace('href ="/','href = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
$text2 = str_replace('href="/','href = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
//Absoloute URIs (src)
$text2 = str_replace('src = "http://','src = "http://mikor.clearlyhosted.org/proxy.php?p=',$text);
$text2 = str_replace('src= "http://','src = "http://mikor.clearlyhosted.org/proxy.php?p=',$text2);
$text2 = str_replace('src ="http://','src = "http://mikor.clearlyhosted.org/proxy.php?p=',$text2);
$text2 = str_replace('src="http://','src = "http://mikor.clearlyhosted.org/proxy.php?p=',$text2);
//Relative URIs (src)
$text2 = str_replace('src = "/','src = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
$text2 = str_replace('src= "/','src = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
$text2 = str_replace('src ="/','src = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri.'/',$text2);
$text2 = str_replace('src="/','src = "http://mikor.clearlyhosted.org/proxy.php?p='.$uri,$text2);
echo $text2;
}
function EchoIt($text){
echo $text;
}
?> |
| |