HOST,'user'=>DBUSER,'password'=>DBPASS,'database'=>DBNAME)); $siteDataObj = new SiteData($dbObj); $stateDataArr = getStateArr($dbObj); $breedsdDataArr = getBreedsArr($dbObj); $dirLink = ""; $cityList = array(); /* RECORDING HITS LEGEND All classifieds breederID, breedID, classifiedID are NULL and pageType = classified By Breed breederID, stateID, classifiedID are NULL, breedID is numeric and pageType = classified By State breederID, breedID, classifiedID are NULL, stateID is numeric and pageType = classified Specific classified breedID and stateID is NULL, breederID and classifiedID are numeric and pageType = classified */ if(!isset($_GET['page']))$_GET['page'] = 1; if(isset($_GET['showall'])){ // show all classifieds $query = "SELECT classifieds.title, classifieds.dateAdded, classifieds.type, state.stateName, breeders.name, breeders.linkName,cities.city, classifieds.id, COUNT(classifiedImages.id) AS imgCount FROM (classifieds LEFT JOIN classifiedImages ON classifieds.id = classifiedImages.ownerID AND classifiedImages.imageData != ''),breeders,state,breeds,cities WHERE classifieds.expires >= NOW() AND classifieds.ownerID = breeders.id AND breeders.active = 1 AND state.id = breeders.state AND breeders.city = cities.id AND classifieds.category = breeds.id GROUP BY classifieds.id ORDER BY IF(breeders.expires >=NOW(),0,1), classifieds.dateAdded DESC, classifieds.id DESC"; $pg=&new Pager($dbObj,$query,40); $resArr = $pg->displayRecords($_GET['page'],"puppy-for-sale"); if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $row['city'] = capFirst($row['city']); $html .= formatListing($row, $a, $siteDataObj); $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

Sorry, we do not have any listings at this time

"; } $pageTitle = "Puppy For Sale Classified Ads"; $metaDescription = "View dog breeder classified ads for puppy litters, finished and started dogs for sale in all dog breeds and locations"; $metaKeywords = "puppy for sale, started dog, finished, litter, puppies, dogs, dog breeders, classified, ads"; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', type = 'incoming', pageType='classified'"); } else if(isset($_GET['state']) && isset($_GET['city'])){ // show classifieds by city // check that state and city exists in database $query = "SELECT state.*, cities.id as cityID, cities.city FROM state, cities WHERE state.stateName LIKE '".Linkformat::stripDashes($_GET['state'])."' AND cities.city LIKE '".Linkformat::stripDashes($_GET['city'])."%' AND cities.stateID = state.id"; $dbObj->performQuery($query); if($dbObj->getNumRows()==0){ $html = showImproperRequest(); } else { $tempStateData = $dbObj->fetchRow(); $thisState = $tempStateData['stateName']; $thisCity = capFirst($tempStateData['city']); $tempCityArr = getCityList($dbObj, $tempStateData['id']); $linkState = Linkformat::addDashes($_GET['state'],lcase); foreach($tempCityArr as $key => $value){ $cityList[] = "siteURL/classifieds/$linkState/".Linkformat::addDashes($key,lcase).".html\">".capFirst($key)." ($value)"; } } $query = "SELECT classifieds.title,classifieds.type, classifieds.dateAdded, state.stateName, breeders.name, breeders.linkName, cities.city, classifieds.id, breeds.breeds, COUNT(classifiedImages.id) AS imgCount FROM (classifieds LEFT JOIN classifiedImages ON classifieds.id = classifiedImages.ownerID AND classifiedImages.imageData != ''),breeders,state,breeds,cities WHERE classifieds.expires >= NOW() AND classifieds.ownerID = breeders.id AND breeders.active = 1 AND state.id = breeders.state AND breeders.city = cities.id AND cities.id = {$tempStateData['cityID']} AND classifieds.category = breeds.id GROUP BY classifieds.id ORDER BY IF(breeders.expires >=NOW(),0,1), classifieds.dateAdded DESC"; $pg=&new Pager($dbObj,$query,40); $resArr = $pg->displayRecords($_GET['page'],$_GET['state']); if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $row['city'] = capFirst($row['city']); $html .= formatListing($row, $a, $siteDataObj); $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

Sorry, we do not currently have any classified ad listings for puppies for sale in $thisCity, $thisState

"; $html .= "

siteURL."/puppy-for-sale.html\">Click here to do another search.

"; } $dirLink = "

siteURL/kennels-{$_GET['state']}/{$_GET['city']}\">Search for breeders in $thisCity, $thisState

"; $pageTitle = "Puppy For Sale Classified Ads - $thisCity, $thisState"; $metaDescription = "View dog classifieds in $thisCity, $thisState for all dog breeds "; $metaKeywords = ""; } else if(isset($_GET['state'])){ // show classifieds by state // check that state exists in database $dbObj->performQuery("SELECT * FROM state WHERE stateName LIKE '".Linkformat::stripDashes($_GET['state'])."'"); if($dbObj->getNumRows()==0){ $html = showImproperRequest(); $pageTitle = "Error"; } else { $tempStateData = $dbObj->fetchRow(); $tempCityArr = getCityList($dbObj, $tempStateData['id']); $linkState = Linkformat::addDashes($_GET['state'],lcase); foreach($tempCityArr as $key => $value){ $cityList[] = "siteURL/classifieds/$linkState/".Linkformat::addDashes($key,lcase).".html\" class=\"breederSMLink\">".capFirst($key)." ($value)"; } } $query = "SELECT classifieds.title,classifieds.type, classifieds.dateAdded, state.stateName, breeders.name, breeders.linkName, cities.city, classifieds.id, breeds.breeds, COUNT(classifiedImages.id) AS imgCount FROM (classifieds LEFT JOIN classifiedImages ON classifieds.id = classifiedImages.ownerID AND classifiedImages.imageData != ''),breeders,state,breeds,cities WHERE classifieds.expires >= NOW() AND classifieds.ownerID = breeders.id AND breeders.active = 1 AND state.id = breeders.state AND breeders.city = cities.id AND state.stateName LIKE '".Linkformat::stripDashes($_GET['state'])."' AND classifieds.category = breeds.id GROUP BY classifieds.id ORDER BY IF(breeders.expires >=NOW(),0,1), classifieds.dateAdded DESC"; $pg=&new Pager($dbObj,$query,40); $resArr = $pg->displayRecords($_GET['page'],$_GET['state']); if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $row['city'] = capFirst($row['city']); $html .= formatListing($row, $a, $siteDataObj); $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

Sorry, we do not currently have any classified ad listings for puppies for sale in ".Linkformat::stripDashes($_GET['state'])."

"; $html .= "

siteURL."/puppy-for-sale.html\">Click here to do another search.

"; } $dirLink = "

siteURL/kennels-".Linkformat::addDashes($_GET['state'],lcase)."/\">Search for breeders in ".Linkformat::stripDashes($_GET['state'])."

"; $pageTitle = "Puppy For Sale Classified Ads - ".Linkformat::stripDashes($_GET['state']); $metaDescription = "View dog classifieds in ".Linkformat::stripDashes($_GET['state'])." for all dog breeds "; $metaKeywords = ""; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', stateID = {$tempStateData['id']}, type = 'incoming', pageType='classified'"); } else if(isset($_GET['breed'])){ // show classifieds by breed $html = ""; $query = "SELECT id,breeds,description FROM breeds WHERE breeds LIKE '".LinkFormat::stripDashes($_GET['breed'])."%'"; $dbObj->performQuery($query); if($row = $dbObj->fetchRow()){ $cbreed = $row['breeds']; $breedID = $row['id']; } else { $html = showImproperRequest(); $pageTitle = "Error"; } $query = "SELECT classifieds.title, classifieds.dateAdded,classifieds.type, state.stateName, breeders.name, breeders.linkName, cities.city, classifieds.id, COUNT(classifiedImages.id) AS imgCount FROM (classifieds LEFT JOIN classifiedImages ON classifieds.id = classifiedImages.ownerID AND classifiedImages.imageData != ''),breeders,state,breeds,cities WHERE classifieds.expires >= NOW() AND classifieds.ownerID = breeders.id AND breeders.active = 1 AND state.id = breeders.state AND cities.id = breeders.city AND breeds.breeds LIKE '".Linkformat::stripDashes($_GET['breed'])."%' AND classifieds.category = breeds.id GROUP BY classifieds.id ORDER BY IF(breeders.expires >=NOW(),0,1), classifieds.dateAdded DESC"; $pg=&new Pager($dbObj,$query,40); $resArr = $pg->displayRecords($_GET['page'],"","breed={$_GET['breed']}&submit=SEARCH"); if(count($resArr['results'])>0){ $html = "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; $a = 0; foreach($resArr['results'] as $row){ $row['city'] = capFirst($row['city']); $html .= formatListing($row, $a, $siteDataObj); $a++; } if($a>5) $html .= "
".$pg->getPageResults($_GET['page'])."
Page {$_GET['page']}   ".$resArr['links']."
"; } else { $html .= "

About the ".$cbreed."
".$row['description']."


"; $html .= "

Sorry, we do not have any listings for this dog breed

"; $html .= "

siteURL.$_SERVER['PHP_SELF']."\">Click here to do another search.

"; } $pageTitle = "$cbreed Classifieds"; $metaDescription = "View all $cbreed dog classified ad listings by sporting dog breeds showing puppy litters, started and finished dogs for sale"; $metaKeywords = "$cbreed, classified ad, dog for sale, puppies, puppy litter, started, finished, dog breeders"; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', breedID = (SELECT id FROM breeds WHERE breeds LIKE '".Linkformat::stripDashes($_GET['breed'])."'), type = 'incoming', pageType='classified'"); } else if(isset($_GET['id']) && is_numeric($_GET['id'])){ // show specific classified $query = "SELECT classifieds.*, breeders.name, breeders.linkName, breeders.id as breederID, state.stateName, breeds.breeds as breedName, cities.city FROM classifieds,breeders,state,breeds,cities WHERE breeders.state = state.id AND classifieds.ownerID = breeders.id AND breeders.active = 1 AND breeders.city = cities.id AND breeds.id = classifieds.category AND classifieds.id = ".$_GET['id']; $dbObj->performQuery($query); if($row = $dbObj->fetchRow()){ $row['city'] = capFirst($row['city']); $html= ""; $breederID = $row['breederID']; $description = $row['description']; $cBreed = $row['breedName']; $formObj->postVars['breed'] = LinkFormat::adddashes($row['breedName'],lcase); $pageTitle = "{$row['title']} - {$row['breedName']} - {$row['name']} - ".((trim($row['city'])!="")?"{$row['city']}, ":"")."{$row['stateName']}"; if(trim($row['email'])!="") $html .= "
siteURL}/contactClassified".$row['id'].".html\" class=\"email\">Email {$row['name']} about this ad.
\n"; $html .= "
$description\n"; $html .= "
Ad location: ".((trim($row['city'])!="")?"{$row['city']}, ":"")."{$row['stateName']}
\n"; $html .= "
Ad created: ".formatDate($row['dateAdded'])."
\n"; $html .= "
"; $html .= "
Contact Information
\n"; $html .= "
\n"; if(trim($row['contactName'])!="") $html .= "Contact Name: ".$row['contactName']."
\n"; if(trim($row['phone'])!="") $html .= "
".$row['phone']."
\n"; if(trim($row['phone2'])!="") $html .= "
".$row['phone2']."
\n"; if(trim($row['cell'])!="") $html .= "
".$row['cell']."
\n"; if(trim($row['email'])!="") $html .= " siteURL}/contactClassified".$row['id'].".html\" class=\"email\">Contact breeder through email\n"; if(trim($row['website'])!="") $html .= "Click here to visit website
\n"; $html .= "
\n"; $html .= "

siteURL."/kennels-".LinkFormat::addDashes($row['stateName'],lcase)."/".LinkFormat::addDashes($row['city'],lcase)."/".LinkFormat::addDashes($row['linkName'],lcase).".html\">".$row['name']." Breeder Information

\n"; $html .= "
\n"; $query = "SELECT count(id) as recCount FROM classifiedImages WHERE ownerId = ".$_GET['id']." AND imageData != ''"; $dbObj->performQuery($query); if($row = $dbObj->fetchRow()){ if($row['recCount']>0) { $html .='
'; } } $metaDescription = showFirst($description,255); $metaKeywords = "$cBreed for sale, $cBreed puppies, started {$cBreed}s, finished, studs, puppy, litter, dog breeder"; // record hit $dbObj->performQuery("INSERT INTO traffic SET mark = NOW(), referringIP = '{$_SERVER['REMOTE_ADDR']}', classifiedID = {$_GET['id']}, breederID= $breederID, type = 'incoming', pageType='classified'"); } else { $html = showImproperRequest(); } } else { $html = showImproperRequest(); } ?> <?= $pageTitle ?> - Dog Breeder Classified Ads metaDescription) ?>"/> metaKeywords) ?>"/> 0){ ?>
Classifieds by city in

Search classified ads by dog breed
siteURL,$formObj) ?>
".((isset($row['imgCount'])&&$row['imgCount']>0)?"siteURL."/images/cameraIcon.gif\" alt=\"\" /> ":"")."siteURL."/classifieds/".$row['id'].".html\">".$row['title']."
"; if($row['type'] != null){ $html .= "Ad type: {$row['type']} | "; } $html .= "Location: ".$row['city']." - ".$row['stateName']."
"; $html .= "Breeder: siteURL."/kennels-".Linkformat::addDashes($row['stateName'],lcase)."/".Linkformat::addDashes($row['city'],lcase)."/".Linkformat::addDashes($row['linkName'],lcase).".html\">".$row['name']." | "; $html .= "Created: ".formatDate($row['dateAdded'])."
"; $html .= ""; return $html; } function getStateList(&$dbObj, &$stateDataArr,$siteURL){ $breedersArr = array(); $itemArr = array(); $query = "SELECT count(classifieds.id) as classifiedCount, breeders.state FROM breeders,classifieds WHERE classifieds.expires >= NOW() AND classifieds.ownerID = breeders.id AND breeders.active = 1 GROUP BY breeders.state"; $dbObj->performQuery($query); while($row = $dbObj->fetchRow()){ $breedersArr[$row['state']] = $row['classifiedCount']; } foreach($stateDataArr as $key => $value){ $itemArr[] = "$value".((array_key_exists($key,$breedersArr))?" (".$breedersArr[$key].")":"").""; } return implode("",$itemArr); } function getBreedList(&$dbObj,&$breedsDataArr,$siteURL,&$formObj){ $breedersArr = array(); $itemArr = array(); $query = "SELECT count(classifieds.id) as classifiedCount, classifieds.category FROM classifieds,breeders WHERE classifieds.expires >= NOW() AND classifieds.ownerID = breeders.id AND breeders.active = 1 GROUP BY classifieds.category"; $dbObj->performQuery($query); while($row = $dbObj->fetchRow()){ $breedersArr[$row['category']] = $row['classifiedCount']; } foreach($breedsDataArr as $key => $value){ if(trim($value)!=""){ $itemArr[LinkFormat::addDashes($value,lcase)] = $value." ".((array_key_exists($key,$breedersArr))?"(".$breedersArr[$key].") ":""); } } return $formObj->selectTag("name=breed",$itemArr); } function getCityList(&$dbObj, $stateID){ $returnArr = array(); $dbObj->performQuery("SELECT ci.*, count(br.id) as breederCount FROM cities ci, breeders br, classifieds cl WHERE ci.stateID = $stateID AND br.city = ci.id AND cl.ownerID = br.id AND cl.expires >= NOW() GROUP BY ci.id ORDER BY ci.city"); while($row = $dbObj->fetchRow()){ $returnArr[capFirst($row['city'])] = $row['breederCount']; } return $returnArr; } ?>