<?php
include('simple_html_dom.php');
function curPageURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
// Retrieve the DOM from a given URL
$html = file_get_html(curPageURL());
str_ireplace("http://martianguy.com","http://new.martianguy.com", $html);
?>
I am trying to replace all links with domain martianguy.com with new.martianguy.com (all href and scr attributes). Is it ok to use the current page url in file_get_html function? When I test this on my localhost, it does not do anything and times out after 30 seconds.