// Storefront v2.0 | Copyright 2004-2007 CBengine.com
// SETTINGS (see Readme.txt)
$CBengine = array();
$CBengine['user'] = “quebecosta”;
$CBengine['cbid'] = “quebecosta”;
$CBengine['cache_time'] = 3600;
$CBengine['cache_path'] = ‘./store_cache/’;
$CBengine['store_name'] = “Your Think Out Of The Box Store”;
$CBengine['store_home'] = “index.php”;
$CBengine['store_css'] = “store.css”;
$CBengine['store_cats'] = “store_cats1.php”;
$CBengine['store_limit'] = 10;
$CBengine['store_paged'] = 7;
$CBengine['store_debug'] = 0;
require(’store_functions.php’);
if (isset($_GET["page"])) { $page = $_GET['page']; }
if(empty($page)){ $page = 1; }
$PHP_SELF = $CBengine['store_home'].”?mall=1″;
$q = “u=” . $CBengine['user'] . “&r=5000″;
if (isset($_GET["kw"])) {
$q .= “&q=” . urlencode(stripslashes($_GET['kw']));
$PHP_SELF .= “&kw=” . urlencode($_GET['kw']);
}
if (isset($_GET["cat"])) {
$q .= “&c=” . urlencode(stripslashes($_GET['cat']));
$PHP_SELF .= “&cat=” . urlencode($_GET['cat']);
}
$file = “http://cbengine.com/search/storefront.cfm?” . $q;
if (isset($_GET["hopid"])) {
// Clicked Link Redirect
// Add any additional tracking code before redirect
$hopid = $_GET['hopid'];
$hoplink = “http://cbengine.net/go/?vtag=store&u=”.$CBengine['user'].”&cbid=”.$CBengine['cbid'].”&hopid=”.$hopid;
header( ‘Location:’ .$hoplink ) ;
} else if (isset($_GET["kw"]) || isset($_GET["cat"])) {
$oRss = new SimpleRss($file, $CBengine['cache_time']);
if ($oRssObject = $oRss->GetRssObject()) {
$totalrows = count($oRssObject->aItems);
$limitvalue = $page * $CBengine['store_limit'] – ($CBengine['store_limit']);
$endrow = min(($page*$CBengine['store_limit']),$totalrows);
$startrow = ($page*$CBengine['store_limit'])-($CBengine['store_limit']);
$oRssObject->aItems = array_slice($oRssObject->aItems, $startrow, $CBengine['store_limit']);
$bulletStart = $startrow+1;
// FOR DEBUGGING
if ($CBengine['store_debug'] > 0) {
if ($oRss->IsCached()) { echo ‘
This feed is cached.
‘; }
if ($oRss->IsStaleCache()) { echo ‘
Unable to parse or retrieve feed.’; }
}
$page_label = ”;
if (isset($_GET["cat"])) {
$catname = trim($oRssObject->oChannel->sTitle);
$page_title = ” . $catname . ‘ products’;
$page_keywords = $catname;
$page_description = $catname;
$backlink1 = ‘Main » ‘;
$backlink2 = ‘‘ . $catname . ‘‘;
$page_label = ”
“.$backlink1.’ ‘.$backlink2 .”
“;
}
// INCLUDE HEADER
include(”store_header.php”);
print (’
‘.”\n”); if($totalrows > 0){
print ($page_label.”\n”);
if (isset($_GET["kw"])) {
$backlink = ‘Main » ‘;
print (’
‘.$backlink.’ ‘.$totalrows.” search results for “.$_GET["kw"].”
“.”\n”);
}
}else{
// No results so load categories
print (’Your search did not return any products.
‘);
if (file_exists($CBengine['store_cats'])) {
$string = get_include_contents($CBengine['store_cats']);
$string = str_replace(’storefront.php’,$CBengine['store_home'],$string);
echo($string);
}
}
// RENDER STORE ITEMS
print (’
- ‘.”\n”);
- ‘.”\n”);
print (’‘.trim($oItem->sTitle).’‘.”\n”);
print (’‘.trim($newtext).’‘.”\n”);
print (”
foreach ($oRssObject->aItems as $oItem) { // $hoplink = trim($oItem->sLink).”&u=”. $CBengine['user'].”&cbid=”.$CBengine['cbid'];$hoplink = $CBengine['store_home'].”?hopid=”.$oItem->shopid;$newtext = str_replace(’,', ‘, ‘, $oItem->sDescription);
print (’
“.”\n”);
}
print (”
“.”\n”);
// RENDER PAGED NAV
if ($totalrows > $CBengine['store_limit']) {
$numofpages = ceil($totalrows/$CBengine['store_limit']);
$midpos = ceil($CBengine['store_paged']/2);
if($page <= $midpos){
$startpage = 1;
} else if ($page >= $numofpages-($midpos-1)){
$startpage = max($numofpages-($CBengine['store_paged']-1),1);
}else{
$startpage = $page-($midpos-1);
}
$endpage = min($startpage+($CBengine['store_paged']-1),$numofpages);
echo ‘
‘;
if($page != 1){
$pageprev = $page-1;
echo(”Prev “);
}
for($i = $startpage; $i <= $endpage; $i++){
if($i == $page){
echo(”$i “);
}else{
echo(”$i “);
}
}
if(($totalrows – ($CBengine['store_limit'] * $page)) > 0){
$pagenext = $page+1;
echo(”Next“);
}
echo ‘
‘;
}
print (”
“);
// INCLUDE FOOTER
include(”store_footer.php”);
}else{
include(”store_header.php”);
print (’
Your search did not return any products.
‘);
include(”store_footer.php”);
}
} else {
// RENDER CATEGORIES
include(”store_header.php”);
print (’
‘.”\n”);
if (file_exists($CBengine['store_cats'])) {
$string = get_include_contents($CBengine['store_cats']);
$string = str_replace(’storefront.php’,$CBengine['store_home'],$string);
echo($string);
} else {
// do nothing
}
print (”
“);
include(”store_footer.php”);
}
?>

