Quote
/* before using this script, create a file cpstore.inc in your main nuke directory
and chmod it 777. It will be used to cache your products. If you add products
to your store, just clear it out and view your page with the block to
re-set the cache file.
To install this script, create a PHP-script block and copy this entire script
into it when prompted for the code. Change the $stores variable below.
*/
// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '';
$end = '';
$stores = 'ttvnshop';
$URL = 'http://www.cafeshops.com/' . $stores;
$itemfile = 'cpstore.inc';
$mode = $_SERVER['QUERY_STRING'];
if (!file_exists($itemfile)) {
echo "create cpstore.inc in your nuke directory and chmod it 777!";
} elseif (filesize($itemfile) == 0) {
echo "Beginning CP item file update...
\n";
// connect to CP
$reqheader = "GET /$stores HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n";
$socket = @fsockopen("www.cafeshops.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("","",$line); ","",$line);
$line = ereg_replace("
$line = ereg_replace("150","100",$line);
$line = ereg_replace("(.*)","",$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("",$line)) {unset ($line);}
if (eregi("",$line)) {unset ($line);}
$line = ereg_replace("/for php use:
echo $item;
}
I been trying to create a block but was not successful..this code I got it from Bao
thnx in advance...
