$j){ $actual_cat .= $j . '/'; $q = preg_replace('/-/',' ',$j); $q = preg_replace('/ /','-',$q); if($q == 'index.php'){ $q = 'local'; } $breadcrumb .= "<= $q >"; } $breadcrumb = preg_replace('/ >$/','',$breadcrumb); array_pop($for_parent); $parent_cat = '/'; foreach($for_parent as $i=>$j){ $parent_cat .= $j . '/'; } $query = "SELECT category,parent,child,keyword from category_relationships WHERE keyword=\"$last\" AND category=\"$sub\" AND parent=\"$cat\" AND child=\"0\" "; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result); $parent = $keyword = $category = $child = ''; if (empty($row)){ foreach($params as $index=>$value){ $value = preg_replace('/-/',' ',$value); $query = "SELECT category,parent,child,keyword from category_relationships WHERE category=\"$value\""; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result); if (!empty($row)){ $parent = $category; $category = $row['category']; $keyword = $row['keyword']; $child = $row['child']; } } } else { $parent = $row['parent']; $category = $row['category']; $keyword = $row['keyword']; $child = '1'; } if(preg_match('/xx\/$/',$actual_cat)){ $myFile = "zips.csv"; $fh = fopen($myFile, 'r'); $zips_full = fgets($fh); $zips_arr = explode(',',$zips_full); array_shift($zips_arr); $ziplist = array(); $par = explode('/',$actual_cat); $zipcode = $par[(count($par)-2)]; $zipshort = substr($zipcode,0,3); foreach($zips_arr as $n=>$line){ if(preg_match("/^$zipshort/",$line)){ $ziplist[$line] = $line; } } print_r("
$breadcrumb

"); foreach($ziplist as $key=>$value){ $value = preg_replace('/ /','-',$value); print_r("$value
"); } } elseif(is_numeric($last)){ $par = explode('/',$actual_cat); $zip = $par[(count($par)-2)]; $keyword = $par[(count($par)-3)]; $keyword = preg_replace('/-/',' ',$keyword); $zip = urlencode($zip); //$url = "http://network.dexknows.com/dexsearchnetwork/SearchNetwork?what=$keyword&where=$zip&partner=rj&mkt=CD1977"; $url = "http://pfp.citysearch.com/pfp?what=".urlencode($keyword)."&where=$zip&publisher=test"; $curl_handle = curl_init (); curl_setopt ($curl_handle, CURLOPT_URL, $url); curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1); // Perform the POST and get the data returned by the server. $dat = curl_exec ($curl_handle) or err("There has been a CURL_EXEC error"); // Close the CURL handle curl_close ($curl_handle); print_r("
$breadcrumb

"); /* $results = getMultiMatch('","","",$result); $site = getSingleMatch("","",$result); if($site=='') { $site = "http://www.dexknows.com/"; } $click = getSingleMatch("","",$result); if(strlen(trim($name))>5) { $listings[] = array("title"=>$name,"description"=>$description,"site"=>$site,"click"=>$click); } } */ $listings = array(); $results = getMultiMatch('',$dat); foreach($results as $result) { $name = getSingleMatch("","<",$result); $description = getSingleMatch("","<",$result); $site = getSingleMatch("","<",$result); $click = getSingleMatch("","<",$result); if(strlen(trim($name))>5) { $listings[] = array("title"=>$name,"description"=>$description,"site"=>$site,"click"=>$click); } } if (empty($listings)){ $url = "http://local.yahooapis.com/LocalSearchService/V3/localSearch?query=".urlencode($keyword)."&zip=$zip&appid=YahooDemo"; $curl_handle = curl_init (); curl_setopt ($curl_handle, CURLOPT_URL, $url); curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1); // Perform the POST and get the data returned by the server. $dat = curl_exec ($curl_handle) or err("There has been a CURL_EXEC error"); // Close the CURL handle curl_close ($curl_handle); $results = getMultiMatch('',$dat); foreach($results as $result) { $name = getSingleMatch("","<",$result); $description = getSingleMatch("<Address>","<",$result).", ".getSingleMatch("<City>","<",$result).", ".getSingleMatch("<State>","<",$result)."<br />".getSingleMatch("<Phone>","<",$result); $site = getSingleMatch("<BusinessUrl>","<",$result); $click = getSingleMatch("<ClickUrl>","<",$result); if(strlen(trim($name))>5) { $listings[] = array("title"=>$name,"description"=>$description,"site"=>$site,"click"=>$click); } } } if(stristr($_SERVER['REQUEST_URI'],"roof") && stristr($_SERVER['REQUEST_URI'],"/080")) { if(stristr($_SERVER['REQUEST_URI'],"43")) { $u = "http://www.fortifiedroofing.com/voorhees-roofing"; } elseif(stristr($_SERVER['REQUEST_URI'],"53")) { $u = "http://www.fortifiedroofing.com/marlton-roofing"; } else { $u = "http://www.fortifiedroofing.com/cherry-hill-roofing"; } echo "<div class='ads'><a href='$u' target='_blank'><strong>Fortified Roofing</strong><span>Fortified Roofing, 1814 Route 70 East, Cherry Hill, NJ 08003<br>(855) 444 3678</span><em>$u</em></a></div>"; } foreach($listings as $key=>$listing){ $title = $listing['title']; $description = $listing['description']; $site = $listing['site']; $click = $listing['click']; echo("<div class='ads'><a href='$click' target='_blank'><strong>$title</strong><span>$description</span><em>$site</em></a></div>"); } } elseif (($parent == '') && ($category == '')){ $query = "SELECT category,parent,child,keyword from category_relationships where parent='0'"; $result = mysql_query($query) or die (mysql_error()); $subs = array(); while($row = mysql_fetch_array($result)){ $temp = $row['category']; $subs[$temp] = $temp; } print_r("<br /> $breadcrumb<br /><br /> "); foreach($subs as $key=>$value){ $value = preg_replace('/ /','-',$value); print_r("<a href='".$replace."$value/'>$key</a><br /> "); } } elseif (($parent == '') && ($category != '')){ $query = "SELECT category,parent,child,keyword from category_relationships WHERE category=\"$category\""; $result = mysql_query($query) or die (mysql_error()); $subs = array(); while($row = mysql_fetch_array($result)){ $temp = $row['child']; $subs[$temp] = $temp; } print_r("<br /> $breadcrumb<br /><br /> "); foreach($subs as $key=>$value){ $value = preg_replace('/ /','-',$value); print_r("<a href='$value/'>$key</a><br /> "); } } elseif(($parent != '') && ($category != '') && ($child != '0') && ($child != '1')){ $query = "SELECT category,parent,child,keyword from category_relationships WHERE category=\"$category\""; $result = mysql_query($query) or die (mysql_error()); $subs = array(); while($row = mysql_fetch_array($result)){ $temp = $row['child']; $subs[$temp] = $temp; } print_r("<br /> $breadcrumb<br /><br /> "); foreach($subs as $key=>$value){ $value = preg_replace('/ /','-',$value); print_r("<a href='$value/'>$key</a><br /> "); } } elseif(($parent != '') && ($category != '') && ($child == '0')){ $query = "SELECT category,parent,child,keyword from category_relationships WHERE category=\"$category\""; $result = mysql_query($query) or die (mysql_error()); $subs = array(); while($row = mysql_fetch_array($result)){ $temp = $row['keyword']; $subs[$temp] = $temp; } print_r("<br /> $breadcrumb<br /><br /> "); foreach($subs as $key=>$value){ $value = preg_replace('/-/','--',$value); $value = preg_replace('/ /','-',$value); print_r("<a href='$value/'>$key</a><br /> "); } } elseif(($parent != '') && ($category != '') && ($child == '1')){ $query = "SELECT category,parent,child,keyword from category_relationships WHERE category=\"$category\" AND keyword=\"$keyword\""; $result = mysql_query($query) or die (mysql_error()); $subs = array(); while($row = mysql_fetch_array($result)){ $temp = $row['keyword']; $subs[$temp] = $temp; } print_r("<br /> $breadcrumb<br /><br /> "); $myFile = "zips.csv"; $fh = fopen($myFile, 'r'); $zips_full = fgets($fh); $zips_arr = explode(',',$zips_full); array_shift($zips_arr); $ziplist = array(); foreach($zips_arr as $n=>$line){ $zip = substr($line,0,3); $ziplist[$zip] = $zip.'xx'; } foreach($ziplist as $key=>$value){ $value = preg_replace('/ /','-',$value); print_r("<a href='$value/'>$value</a><br /> "); } } ?> </div><br /> <div id='recent'> <b>Latest Listing</b>: Fortified Roofing<br /><br /><div id='rlisting'></div></div> <script>divToSelect('rlisting');</script> <? require_once('footer.php'); function getMultiMatch($start,$end,$content) { $arr = array(); $exp = explode($start,$content); for($i=1;$i< count ( $exp );$i++) { $exp2 = explode($end,$exp[$i]); $arr[] = $exp2[0]; } return $arr; } function getSingleMatch($start,$end,$content) { $exp = explode($start,$content); if ($end == 'EndOfFile'){ return($exp[1]); } $exp2 = explode($end,$exp[1]); return $exp2[0]; } ?> <script>divToSelect('content');</script>