'; echo "This is the full path to your web directory on your server. If you can, put your \"cookies\" folder up 1 level from your live web folder (www, htdocs, public_html, etc..)"; $tmp = explode("/",$_SERVER['DOCUMENT_ROOT']); //build out what could work as their cookies directory $tmpCount = count($tmp); $dirStr = "/"; for($i=0;$i<$tmpCount-1;$i++) $dirStr.= $tmp[$i] . "/"; $dirStr = str_replace("//","/",$dirStr . 'cookies/'); echo "

The cookies directory you make should look something like this: '$dirStr'
"; die(); } /* If a form is submitted, we need to post these to the URL we access */ if($_POST) { $postVars =''; //Flush foreach($_POST as $k=>$v) { $postVars .= $k . "=" .$v . "&"; //Build a GET style string for posting //echo "post: $k - $v
"; } $postVars = substr($postVars,0,-1); //Remove trailing & character } /* Detect which IDX page is being accessed and remove the prefixes from it */ $page = str_replace("/". IDX_DIRECTORY . "/","",$_SERVER['REQUEST_URI']); /* Build the full URL path to the corresponding IDX Page */ $url = 'http://' . CLIENT_SUB_DOMAIN . '.idxco.com/idx/' . CLIENT_ID . '/' . $page; /* Open URL and store contents to an array */ $ch = curl_init(); // initialize CURL $timeout = 0; // set to zero for no timeout $cookie = COOKIE_DIR . 'cookie-'. str_replace(".","",$_SERVER['REMOTE_ADDR']) . '.txt'; //set cookie path, IP address for unique $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"; curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // required for many of the IDX pages curl_setopt($ch, CURLOPT_URL, $url); // url at to open curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // yes to allow some editing before output curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); //set timeout curl_setopt($ch, CURLOPT_POST, 1); // post? curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars); // vars to be posted curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); // sets the cookie file location curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); // this says to start a new cookie file. //curl_setopt($ch, CURLOPT_COOKIE, $cookie); // use the cookie we have on file $file_contents = curl_exec($ch); curl_close($ch); $lines = array(); $lines = explode("\n", $file_contents); // load html into a file /* Output the file line by line while re-routing the links to match your domain */ foreach($lines as $line_num => $line) { /* Reproduce each link on the site to point to your server instead of the idxco.com pages */ $line = preg_replace("/\&key=(.*)\" type=/", "&key=".GMAP_KEY."\" type=", $line); $line = str_replace("http://idxco.com/idx/" . CLIENT_ID . "/", "http://" .CLIENT_DOMAIN . "/" . IDX_DIRECTORY . "/", $line); $line = str_replace("http://www.idxco.com/idx/" . CLIENT_ID . "/", "http://www." .CLIENT_DOMAIN . "/" . IDX_DIRECTORY . "/" , $line); $line = str_replace("http://www." . CLIENT_SUB_DOMAIN . ".idxco.com/idx/" . CLIENT_ID . "/", "http://www." .CLIENT_DOMAIN . "/" . IDX_DIRECTORY . "/" , $line); $line = str_replace("http://" . CLIENT_SUB_DOMAIN . ".idxco.com/idx/" . CLIENT_ID . "/", "http://www." .CLIENT_DOMAIN . "/" . IDX_DIRECTORY . "/", $line); $line = str_replace("/idx/" . CLIENT_ID . "/", "/" . IDX_DIRECTORY . "/", $line); $line = str_replace('src="/javascript', 'src="http://idxco.com/javascript', $line); print $line . " \n"; //print the HTML after going through link filters } ?>