Dynadot โ€” .com Transfer

Need a bit of help (eregi_replace not working)

Spaceship Spaceship
Watch

Barrucadu

Established Member
Impact
64
DEMO: http://mikor.clearlyhosted.org/proxy.php?p=http://www.google.com
If you view the source (or hover over the links) the target path hasnt been changed properly... heres the code:
PHP:
<?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");
$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'];
	//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;
}
?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
PHP:
<?php

$page = $_GET['p'] = 'http://www.dnwhois.net';
$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");
$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);
}
else if(in_array($ext, $exts['application']))
{
    header("Content-type: application/".$ext);
    EchoItIt($contents);
}
else if(in_array($ext, $exts['image']))
{
    header("Content-type: image/".$ext);
    EchoIt($contents);
}
else if(in_array($ext, $exts['video']))
{
    header("Content-type: video/".$ext);
    EchoIt($contents);
}
else if(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'];

    //Absoloute URIs (href)
    $text2 = preg_replace('#href(=|\s=|=\s|\s=\s)"http:\/\/#i', 'href="http://mikor.clearlyhosted.org/proxy.php?p=', $text);

    //Relative URIs (href)
    $text2 = preg_replace('#href(=|\s=|=\s|\s=\s)"(\/|)#i', 'href="http://mikor.clearlyhosted.org/proxy.php?p=' . $uri . '/', $text2);

    //Absoloute URIs (src)
    $text2 = preg_replace('#src(=|\s=|=\s|\s=\s)"http:\/\/#i', 'src="http://mikor.clearlyhosted.org/proxy.php?p=', $text2);

    //Relative URIs (src)
    $text2 = preg_replace('#src(=|\s=|=\s|\s=\s)"(\/|)#i', 'src="http://mikor.clearlyhosted.org/proxy.php?p=' . $uri . '/', $text2);
    echo $text2;
}

function EchoIt($text)
{
    echo $text;
}

?>
Ugly regex, but it works.
 
0
•••
Can you explain the "#src(=|\s=|=\s|\s=\s)"(\/|)#i", I have no idea what it means, lol
 
0
•••
Appraise.net
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back