PDA

View Full Version : Cafe Press mod


agiacosa
01-28-2005, 12:14 AM
I can't believe that there isn't a Cafe Press mod for vB3. There's one for phpBB2. Anyone care to take a stab at it?

Reeve of shinra
01-28-2005, 12:28 AM
I know what cafe press is, but whats the mod do exactly?

agiacosa
01-28-2005, 12:43 AM
It pulls your items from your Cafe Press shop and displays them in a vB3 page of its own. It shows item picture plus price. A member can click on it and be taken to the appropriate Cafe Press page to purchase the item.

MR-2ZZ
01-28-2005, 08:07 AM
<a href="http://www.driftchat.com/index.php?page=shop" target="_blank">http://www.driftchat.com/index.php?page=shop</a>

Like this? This is how my site is.

Creed
01-28-2005, 08:26 AM
I would like that as well, very nice :)

agiacosa
01-28-2005, 09:14 AM
http://www.driftchat.com/index.php?page=shop

Like this? This is how my site is.

That's exactly it. How did you do that?

noppid
01-28-2005, 11:06 AM
Pay for a premium shop.

agiacosa
01-28-2005, 01:34 PM
I do have a premium shop.

noppid
01-28-2005, 01:40 PM
I do have a premium shop.

Go to your setup at cafepress and get the HTML to have your items on your site.

Emmbed the necessary HTML you get into a vB page using the portal as above or use the hack that let's you create a vB page with custom content.

Not a tough job at all.

base
01-28-2005, 02:08 PM
use something like the free script from here (http://www.notonebit.com/projects/cafe/free/). // basic store only, i didn't know you had an advanced store before posting this...

i am currently still using it in vb2, but it looks like a piece of cake to add it to a vb3 installation, either via vbacmps (as above) or via another page that allows you to parse template calls in, many how-tos around the site already.

agiacosa
01-28-2005, 02:56 PM
Thanks for the script link but you can't parse php inside of templates. How would I go about doing this?

noppid
01-28-2005, 05:38 PM
That script is cool, however it tags the links to route you to some sales farm or something.

base
01-28-2005, 08:15 PM
Thanks for the script link but you can't parse php inside of templates. How would I go about doing this?

from the script itself -

"...4. You can run this script as an include file within an existing PHP page, cutting-and-pasting the script into your own PHP page, or as a standalone page. If you choose to run it as a standalone page, you'll need to add the appropriate HTML around it in order for it to display properly (<HTML><HEAD><BODY> etc...)...."

like i said, use it with either vbacmps, or another hack which allows you to make your own php pages that show your header/footer etc.

That script is cool, however it tags the links to route you to some sales farm or something.

no it doesn't.

noppid
01-28-2005, 08:33 PM
Well then what in the world is this for?


ereg_replace("<a href=\"","<a href=\"http://www.sealfans.net/store.php?target=http://www.cafepress.com",$line);


With that line in the links they go to netster, removing that part of the URL's sends the user to the proper cafepress store.

Looks like spyware or spamware to me, but that's just a guess. User beware.

base
01-29-2005, 02:08 PM
i can't find that line of code in the script at all. maybe you have an error between the computer and your seat? :ermm:

noppid
01-29-2005, 02:26 PM
i can't find that line of code in the script at all. maybe you have an error between the computer and your seat? :ermm:


This is obviously something he has control of and changed IMO cause he got busted hijacking peoples links. This is the script that was there yesterday...

Every Link was hijacked with...

http://www.sealfans.net/store.php??target=

The other possibility is that they got the script and posted it not having any real clue what the code did. Not for me to judge I guess, but the facts are the facts, that script was changed overnight.


<?

/*
------------------------------------------
RANDOM CafePress ITEM DISPLAY SCRIPT 1.0.9
------------------------------------------
This script is designed to allow CafePress store owners to feature a random item from
any of their CafePress stores on any page of their own web site.

Created and copyright by admin@notonebit.com Feb-16-2003
Last modified: Sept-29-2004

This code is released under the terms of the GNU General Public License
A copy of the GPL can be found at http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

Please retain this message at the top of this script if you modify it in any way.
---------------------------------------------------------------------------------
INSTRUCTIONS:

1. First, your web server must have PHP 4.1.0 or later installed for this script to function properly.
You must also be able to run the fsockopen function.

2. This script has three functions. First, the update function will create a text file on your web
server that contains a list of items from the stores you specify. Run this script like
http://www.yourserver.com/cprand.php?update to update the text file anytime you add/change/delete
an item from any of the stores you've setup the script to use. I used a local text file to greatly
increase the speed of the script. By storing the file locally it saves several seconds on the execution
by reading a local text file versus having to contact CafePress each time the script gets called.
Trust me, it helps.

3. To run the script as a PHP file, comment out the line after "//for javascript use:" that begins
with echo, and uncomment the line after "//for php use:". You can then drop this code in an existing
PHP page, or use the PHP include function.

4. To run the script as a JavaScript comment out the line after "//for php use:" that begins
with echo, and uncomment the line after "//for javascript use:". Then in your HTML page, use the following
code: <script src="cprand.php"></script> making sure that the path to the file is correct.

5. You may need to create a blank text file named cpitemfile.inc (the file that stores the data) and also
change its permissions to 666. Some servers will need this, others won't. Try skipping this step first and
if you get an error during the update, then create the file with these permissions.

6. Finally, make sure to rename this file with a .php extension.

A few notes:
The script was designed to let you put a product's image and description on any page of your web site.
I have designed it to change the image dimensions from CafePress' 150x150 to 100x100. Feel free to
change this by either modifying, deleting, or commenting out the line, "$line = ereg_replace("150","100",$line);". I also
designed it to not display the price of a product. To have the script display the price, delete or comment
out the line, "$line = ereg_replace("<b>(.*)</b>","",$line);". For those of you using fbomb's custom CP store script,
you can have this script link the random item to the detail page for that item on fbomb's script, in fact this is this
scripts default behavior. To have the random item linked to your CafePress store, delete or comment out the line:
"$line = ereg_replace("prod.aspx\?","prod&",$line);" and change the line "$line = ereg_replace("<a href=\"","<a href=\"http://
www.yourwebsite.com/store.php?target=http://www.cafepress.com",$line);" to "$line = ereg_replace("<a href=\"","<a href=\"http://www.cafepress.com",$line);
".

-Scanman20

-------------- SCRIPT BEGINS AFTER THIS LINE -----------------------------------------------*/

// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '<!-- ### Items ### -->';
$end = '<!-- ### end of ITEMS ### -->';
$stores = 'riderinfo';
$url = 'http://www.cafepress.com/' . $stores;
$itemfile = '/home/lakecs/vbg_photos/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.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n";
$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.sealfans.net/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:
echo $item;
}
?>

base
01-29-2005, 02:41 PM
actually, that wasn't the script that i was referring to in my original post, it was the first one on the download page.

noppid
01-29-2005, 06:06 PM
actually, that wasn't the script that i was referring to in my original post, it was the first one on the download page.

Well that explains us not uderstanding each other.

It's still interesting how this seems to have played out. Others must have asked for the revision seen on that site to be posted.

Folks need to be aware of the difference.

SVTBlackLight01
01-29-2005, 06:22 PM
I threw together a quick Cafe Press store with the script at this link (http://www.notonebit.com/projects/cafe/free/) posted earlier. For being so simple it's not too bad. Check it out here (http://www.modernengineuity.com/cafe.php)

Creed
01-29-2005, 09:59 PM
Very nice, happen to want to share with us? I'd really like to add it to my forums as well!

noppid
01-30-2005, 12:11 AM
Hope this helps someone... https://vborg.vbsupport.ru/showthread.php?p=604689#post604689

Cheers!

Creed
01-30-2005, 01:32 AM
I've made my own little add-on using the script that was provided earlier. You can add your own, using my simple mod attached to this post.

I've also added this in the "integration with vbulletin" subforum:
https://vborg.vbsupport.ru/showthread.php?t=75397