<?php
$auth_str = $ModName . "::";
if($pnconfig[Version_Sub] == "Rogue")
{
if (!authorised(0, $auth_str, "::", ACCESS_READ)) die ("Permission denied.");
if (!defined("LOADED_AS_MODULE")) die ("You can't access this file directly...");
}
else
{
if (!eregi("modules.php", $PHP_SELF)) die ("Access Denied");
}
$index = $cpconfig[index];
include ("header.php");
OpenTable();
echo "<h2><a href=\"http://www.cafepress.com/cp/info/storeref.aspx?refby=rastafari\" target=\"_blank\">"
."<img src=\"modules/$ModName/images/pbcp.gif\" border=0 alt=\"Click to set up your own store, or just to search others!\" targe
t=\"_blank\" align=right></a>CafePress Store for $sitename</h2>";
echo "<BR><BR><table width=\"100%\"><tr>\n<td align=\"right\"><a href=\"$cpconfig[cartURL]\">";
echo "<b>View Cart</b>";
$gui = $cpconfig[gui];
if($gui):
echo "<img alt=\"View Cart\" border=0 src=\"modules/$ModName/images/cart.gif\">";
endif;
echo "</a></td>\n</tr></table>";
CloseTable();
function CP_Stores($store)
{
echo "only one store";
}
function cpshow($multi)
{
global $pntable, $ModName;
include("modules/$ModName/classes/products.php");
$prod_types = mysql_query("SELECT ptype FROM $pntable[cp_products] WHERE active='1' GROUP BY ptype");
if (!$multi)
{
echo "<table><tr>\n";
while (list($ptype) = mysql_fetch_row($prod_types))
{
echo "<td>"
."<a href=\"modules.php?op=modload&name=$ModName&file=index&cpop=show_type&type=$ptype\">"
."<img src=\"modules/$ModName/images/$product_images[$ptype]\" border=0><br>"
."$products[$ptype]"
."</a></td>\n";
}
echo "</tr></table>\n";
$sesonals = mysql_query("SELECT * FROM $pntable[cp_seasonal] WHERE active='1' AND NOW() <= expire");
echo "<table><tr>\n";
while ($item = mysql_fetch_array($sesonals))
{
echo "<td>"
."<a href=\"modules.php?op=modload&name=$ModName&file=index&cpop=show_detail&seasonal=1&product=$item[prod]\">"
."<img src=\"http://images.cafepress.com/prodtn_nocache/$item[prod]_$item[def_view]_TN.jpg\" border=0 width=152 height=152><br>"
."$item[name]"
."</a></td>\n";
}
echo "</tr></table>\n";
}
else
{
echo "<table>";
$i = 0;
while (list($type) = mysql_fetch_row($prod_types))
{
cptype($type);
}
echo "</table>";
cptype('99');
}
}
function cptype($type)
{
global $pntable, $ModName,$i;
if ($type < 99) $prods = mysql_query("SELECT * FROM $pntable[cp_products] WHERE ptype='$type' AND active='1'");
elseif ($type == 99)
{
$prods = mysql_query("SELECT * FROM $pntable[cp_seasonal] WHERE active='1' AND NOW() <= expire");
$seasonal = '&seasonal=1';
}
while ($item = mysql_fetch_array($prods))
{
$i++;
if($i % 2) echo "<tr>";
echo "<td><a href=\"modules.php?op=modload&name=$ModName&file=index&cpop=show_detail$seasonal&product=$item[prod]\">"
."<img src=\"http://images.cafepress.com/prodtn_nocache/$item[prod]_$item[def_view]_TN.jpg\" width=140 height=140 border=0><br>"
."$item[name]</a><br>"
."<b>\$$item[charge]</b><br>"
."$item[description]"
."</td>";
if(!$i % 2) echo "</tr>";
}
}
function cpdetail($product,$seasonal)
{
global $pntable, $ModName, $nukeurl,$quantity,$selected_size;
if(isset($quantity) && isset($selected_size)) $doUpdate = true;
if($quantity < 1) $quantity = 1;
if (!$seasonal) $item = mysql_fetch_array(mysql_query("SELECT * FROM $pntable[cp_products] WHERE prod='$product'"));
else
{
$item = mysql_fetch_array(mysql_query("SELECT * FROM $pntable[cp_seasonal] WHERE prod='$product'"));
$item[ptype] = '99';
}
list($store) = mysql_fetch_row(mysql_query("SELECT acct FROM $pntable[CP_Stores] WHERE id='$item[store]'"));
echo "<form method=\"post\" action=\"modules.php\">\n";
echo "<input type=\"hidden\" name=\"product_id\" value=\"$item[prod]\">\n";
echo "<input type=\"hidden\" name=\"name\" value=\"$ModName\">\n";
echo "<input type=\"hidden\" name=\"file\" value=\"cart\">\n";
if($doUpdate):
echo "<input type=\"hidden\" name=\"cpop\" value=\"updateProduct\">\n";
else:
echo "<input type=\"hidden\" name=\"cpop\" value=\"addProduct\">\n";
endif;
echo "<input type=\"hidden\" name=\"op\" value=\"modload\">\n";
echo "<img name=\"mainimg\" src=\"http://images.cafepress.com/prodtn_nocache/$item[prod]_$item[def_view]_TN.jpg\"><br>".showfb($item[ptype],$item[prod]);
if ($item[ptype] == '8') echo "<img src=\"modules/$ModName/images/hatswatches.jpg\" width=\"166\" height=\"75\" alt=\"\" border=\"0\">";
echo "<a href=\"http://www.cafepress.com/cp/store/zoom.aspx?prodno=$item[prod]\">[ Zoom ]</a>"
.""
.""
."<h3>$item[name]</h3>"
."$item[description]<br>"
."<b>\$$item[charge] each</b>"
."<br><br>"
."<table border=0 width=\"100%\">"
."<tr><td>Quantity:<br><input name=\"quantity\" value=\"$quantity\" size=\"4\"></td>"
.showsizes($item[ptype],$item[prod]);
if ($item[ptype] == 8) echo "<td>Color:<br><select name=\"color\"><option selected value=\"1\">White</option><option value=\"2\">Khaki</option><option value=\"3\">Grey</option></select></td>";
echo "</tr></table><br><br>";
if($doUpdate):
echo "<input type=\"submit\" Value=\"Update Cart\" >";
else:
echo "<input type=\"submit\" value=\"Add to Cart\">";
endif;
echo "</form>";
}
OpenTable();
switch ($cpop)
{
case 'one_store':
CP_Stores($store);
break;
case 'show_detail':
cpdetail($product,$seasonal);
break;
case 'show_type':
cptype($type);
break;
default:
cpshow($cpconfig[multi_view]);
}
CloseTable();
echo "<br>";
include ("footer.php");
?>