<?

# Set up URL of your Almond Classifieds script
#$classf_url="http://www.chiropracticjobfinder.com/chiropracticjobfinderSEO/index.php";
$classf_url="http://www.chiropracticjobfinder.com/index.php";

#############################################################

if($_POST!=""){$HTTP_POST_VARS=$_POST;}
if($_COOKIE!=""){$HTTP_COOKIE_VARS=$_COOKIE;}
if($_GET!=""){$HTTP_GET_VARS=$_GET;}
if($_FILES!=""){$HTTP_POST_FILES=$_FILES;}


$get_qr=getenv ("QUERY_STRING");
$http_qr="$classf_url"."?$get_qr";

$fll=fopen($http_qr, "r");
while (!feof($fll)){$html_result=$html_result.fgets($fll,1024);}

$url_base=ereg_replace ("index.php", "", $classf_url);

preg_match_all ("/href='(index.php.*')/esU", $html_result, $matches);
 
$url_matches=$matches[1];
$ii=0; 

$html_result=preg_replace ("/href=[',\"]index.php[',\"]/U", "href='../'", $html_result);

foreach ($url_matches as $value)
{
$url_mat=$url_matches[$ii];
preg_match("/^index.php\?.*ct=(.*)[&,'].*$/U", $url_mat, $mtch_ct);
preg_match("/^index.php\?.*md=(.*)[&,'].*$/U", $url_mat, $mtch_md);
preg_match("/^index.php\?.*mds=(.*)[&,'].*$/U", $url_mat, $mtch_mds);
preg_match("/^index.php\?.*id=(.*)[&,'](.*)$/U", $url_mat, $mtch_id);
preg_match("/^index.php\?.*page=(.*)&.*$/U", $url_mat, $mtch_page);

if (($mtch_ct[1]!=""  and $mtch_mds[1]=="" and  ($mtch_md[1]=="" or $mtch_md[1]=="browse")) or ($mtch_md[1]=="details" and $mtch_id[2]=="")){
if($mtch_md[1]=="details"  ){$url_repl[$ii]="../det/$mtch_id[1]".".html'";}
if($mtch_ct[1]!="" and $mtch_md[1]=="") 
{$url_repl[$ii]="ctg".$mtch_page[1]."/".$mtch_ct[1].".html'";}

if($mtch_ct[1]!="" and $mtch_md[1]=="browse" and $mtch_mds[1]=="")
{$url_repl[$ii]="../ctg".$mtch_page[1]."/".$mtch_ct[1].".html'";}
}
else {$url_repl[$ii]=$url_base.$url_matches[$ii]; }  

 

$url_matches[$ii]="/$url_matches[$ii]/U"; 



$url_matches[$ii]=ereg_replace ("\?", "\?",$url_matches[$ii]);
$url_matches[$ii]=ereg_replace ("\+", "\+",$url_matches[$ii]);

$html_result=preg_replace ($url_matches[$ii], $url_repl[$ii], $html_result);

$ii++;
}


$html_result=preg_replace ("/src='sph.php/U", "src='{$url_base}sph.php", $html_result);

$html_result=preg_replace ("/href=[',\"]style.css[',\"]/U", "href='{$url_base}style.css'", $html_result);

echo $html_result;

exit;

?>