Quote by ScurvyDawg:I am not sure I even still have the code but notonebit does and if destroyer wants to release it he can but it will be tough as there is a bit if a process to get it working right.
I guess somebody would just have to contact me and ask..
Text Formatted Code
function phpblock_randshop() {
global $_CONF;
// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '<!-- ### Items ### -->';
$end = '<!-- ### end of ITEMS ### -->';
$stores = 'YOURSTORE';
$url = 'http://www.cafepress.com/' . $stores;
$itemfile = '/path/to/geeklog/system/cpitemfile.inc';
$mode = $_SERVER['QUERY_STRING'];
if ($mode == "update") {
echo "Beginning CP item file update...<br>n";
// connect to CP
$reqheader = "GET /$stores HTTP/1.0rnHost: www.cafepress.comrnUser-Agent: MS Internet Explorerrnrn";
$socket = @fsockopen("www.cafepress.com", 80, &$errno, &$errstr);
if ($socket)
{
fputs($socket, $reqheader);
while (!feof($socket))
{
$cpfile .= fgets($socket, 4096);
}
}
fclose($socket);
$items = eregi("$start(.*)$end", $cpfile, $cparray);
$newcparray = split ("n", $cparray[1]);
foreach ($newcparray as $line) {
if (strlen($line) > 100)
{
$newestcparray[] = $line;
}
}
$handle = fopen($itemfile, "w");
foreach ($newestcparray as $line) {
$line = ereg_replace("<td align="center" valign="top"><p>","",$line);
$line = ereg_replace("</td>","",$line);
$line = ereg_replace("150","100",$line);
$line = ereg_replace("<b>(.*)</b>","",$line);
// $line = ereg_replace("\$(.*)r", "r", $line); // Uncomment to hide prices
$line = ereg_replace("prod.aspx?","prod&",$line); //this line is just used to integrate with custom store. delete to use regular cp store.
if (eregi("<td colspan=3>",$line)) {unset ($line);}
if (eregi("<tr>",$line)) {unset ($line);}
$line = ereg_replace("<a href="","<a href="http://www.okanagangirlz.com/store.php?target=http://www.cafepress.com",$line);
$line = ereg_replace("src="/cp/img","src="http://www.cafepress.com/cp/img",$line);
if (!empty($line)) {
$lastcparray[] = $line;
fwrite($handle, $line);
}
}
fclose($handle);
echo "CP item file update completed.n";
}
else {
$itemhandle = fopen($itemfile, "r");
$itemarray = fread($itemhandle,filesize("$itemfile"));
fclose($itemhandle);
$lastcparray = split ("r", $itemarray);
$item = $lastcparray[rand(0,count($lastcparray)-2)];
$item = ereg_replace("[x27]",'',$item);
$item = trim($item);
//for javascript use:
//echo "document.write('<div align="center">" . $item . "</div>');";
//for php use:
$theitem = '<div align="center">' . $item . '';
$theitem .= '<a href="' . $_CONF['site_url'] . '/store.php"><strong>More Products</strong></a></div>';
return $theitem;
}
}
Edit the $stores = 'YOURSTORE'; and $itemfile = '/path/to/geeklog/system/cpitemfile.inc'; lines.
"I love deadlines. I like the whooshing sound they make as they fly by." -- Douglas Adams