Location: PHPKode > projects > Simple Browser Proxy > SBP-0.3.2-development/index.php
<?	include			'../../public_html/config.inc.php';
	$absolutePath	=	$absPath;
$start_time = microtime();	//get progs start time for calc run time for later.//
require "Fetcher.class.inc";
require "SBP.class.inc";
include_once "config.inc";

$fetcher = new Fetcher;		//new class for fetching//

$sbp = new SBP;		//new class for manipulating input//

//Made obsolete by the onclick handler in javascript...keeping for ppl who don't want to have to use javascript.
$form_url	=	$_POST['form_url'];
	$url = $form_url;	//	get the url that the user had in input when they submitted the form	//
	$url	=	$_GET['url'];
	if(empty($url))		$url = $default_url;

//Check the URL for protocol etc....
if(substr($url, 0, 7)	!= "http://")	//didn't start with 'http://'...we have a problem.//
	$url	=	"http://".$url;

if(substr($url, -6)==".cache")	//it's a cached image....don't fetch it...just open it!//
	//have to parse out the 'cache/' in the url!!
	//http://www.sufferingfools.net/dev-sbp/cache/ IS 44 long so parse that out!
	$url	=	substr($url, strlen($web_path_to_cache));
	$cached_source	=	@fopen($path_to_cache.$url, "r");
	$HTML		=	@fread($cached_source, filesize($path_to_cache.$url));
	$sbp->setHeaders($HTML, FALSE);	//pass the file's contents to the setHeader() func and inform it that it's a file//
	echo $HTML;
else	//url wasn't a cache file....
	//Check if there was a form redirected to SBP.//
		$form_submission	=	true;
	else if(!empty($_GET['original_url']))
		//have to strip off any unwanted stuff from original_url
		$url	=	explode(" ", $_GET['original_url']);
		$url	=	$url[0];
		$form_submission	=	false;
		$url	=	urldecode($url)."?".str_replace("original_url=".urlencode($_GET['original_url'])."&", "", $_SERVER['QUERY_STRING']);
		//$url	=	urldecode($url)."?".$_SERVER['QUERY_STRING'];
//		$fetcher->referer	=	$_GET['original_url'];
/*		echo "<!--
		ORIGINAL_URL: ".urlencode($_GET['original_url'])."\n
		FORM GET URL: ".$url."\n
		REFERER: ".$fetcher->referer."-->\n";
	if(!$form_submission)	//OK, no redirected form so go ahead and fetch a page.//
			//get the page's source//
			$HTML = $fetcher->results;
			$HTML = $sbp->prependTitle($HTML, $title_tag);
				//make the HTML source more difficult to match patterns to.//
				$HTML = $sbp->scrambleHTML($HTML);
				//make the HTML source more difficult to match patterns to.//
				$HTML = $sbp->scrambleURL($HTML);
			//complete local links so that they are fully qualified URIs//
			$HTML = $sbp->completeURLs($HTML, $url, $title_tag);
				//replace all domain names with just their IP//
				$HTML = $sbp->domain2IP($HTML);
				//fetch the images and cache them locally and replace the URLs to them with a URL to the local cache//
				$HTML = $sbp->cacheFiles($HTML);
			//prepend the URL to this page so that all links go through the proxy//
			$HTML = $sbp->proxyURLs($HTML, $title_tag);
				//	embed my javascript menu	//
				$HTML = $sbp->embedMenu($HTML, $url);
			//set any headers that need to be set.//
			$sbp->setHeaders($url, TRUE);
			//If set true, uses a javascript func that will hide the source from the user && the user's filters  :)//
				require 'Crypt.php';
				$c	=	new HTML_Crypt($HTML);
				$HTML	=	$c->getScript();
			//ouput the page..so that frames atleast partially are written.	//
			//make sure that the cache hasn't grown too large//
			echo ("\n\n<!-- Version: ".$version." -->\n");
			//	Calculate execution time and add comment with that info	//
			$execution_time = $sbp->processTime($start_time, microtime());
			$execution_time = sprintf("%0.3f", $execution_time);
			echo ("<!-- Simple Browser Proxy took $execution_time seconds -->\n");
			echo "Document failed to load: ".$fetcher->error."\n";
	if(!empty($sbp->debug) && $isDebug)
		//Output any debugging information//
		echo "\n<!--\tBEGIN:\tSBP DEBUGGING INFORMATION\n================================================";
			echo "\t".$sbp->debug;
			echo "\tURL: ".$url."\n";
		echo "================================================\n\tEND:\tSBP DEBUGGING INFORMATION -->\n";
	echo "<center>\n";
	echo include $absolutePath.'themes/default-hori.js';
	echo "</center>";
Return current item: Simple Browser Proxy