Posted on: 11/21/03 10:06pm
By: ScurvyDawg
I have been working with a script that I found, it grabs your Cafepress Stores Products and puts them into your site.
I have hit a roadblock in woking with the script and have not been able to get it to integrate with GL correctly. I am wondering if anyone here is willing to look at it and see if they can see what I do not.
email me at scurvydawg@scurvydawg.com if you would like a copy of the script.
Re:CafePress script for GL
Posted on: 11/23/03 01:16am
By: ScurvyDawg
bump
Re:CafePress script for GL
Posted on: 11/27/03 08:39pm
By: ScurvyDawg
Well it works not but there are still a few small issues.
Take a look.
here
Thanks for your Help Rob, you rock.
Now you will see that currently the left menu item does not work right, nor does the site background work on the main store page. However it does work in pages that are one link deep. Otherwise it is fully functional.
Re:CafePress script for GL
Posted on: 11/27/03 11:16pm
By: Blaine
Nice job ScurvyDawg
Re:CafePress script for GL
Posted on: 11/28/03 12:47am
By: jager
Yeah this really rocks. Definitely let us know if you figure out the remaining issues - this is a great enhancement!
Thanks SD!
Re:CafePress script for GL
Posted on: 11/28/03 10:48am
By: ScurvyDawg
Thanks guys.
I am happy to send it to anyone at this point, although until these few issues are resolved I do not think it is prudent to release it to the whole community, broken like it is.
If anyone wants it just email me scurvydawg.scurvydawg.com the . is the @ of course.
If you do make any changes that either add or fix something be sure to send it back to me so those changes can be incorperated into the final script.
hehehe
Re:CafePress script for GL
Posted on: 12/01/03 04:20pm
By: jager
The biggest problem I have right now is that if someone wants to see the larger display of a graphic, it just displays a blank image. Looks like you're having the same problem, Scurvy. I can't figure out how to fix it - anyone have a suggestion?
Re:CafePress script for GL
Posted on: 12/01/03 05:28pm
By: destr0yr
Another issue when viewing the larger image... @ the bottom of the page is a link for Legal info. The link is wrong though... the preg_replace on line 107. I've been trying to figure out what's wrong, but having no experience with PHP i'm pulling up a blank...
Re:CafePress script for GL
Posted on: 12/02/03 08:49pm
By: ScurvyDawg
The issues you two mention are exactly why I have not realeased this fully yet. If either of you are able to correct any of these small issues please let me know.
When all of these things are fixed I will release it to the entire GL community. Anyone who may have some insight into the issues please just email me for a copy of the script.
Cheers
Re:CafePress script for GL
Posted on: 12/07/03 04:05am
By: ScurvyDawg
I have submited a wonderful little script to the GeekLog admins that allows you to create a store at CafePress.com
join here and have it displayed within your GeekLog installation with ease.
See mine in action
Here
Everyone will want this script.
You can download it
Here[*3] .
Re:CafePress script for GL
Posted on: 12/07/03 08:35am
By: destr0yr
[QUOTE BY= ScurvyDawg] See mine in action
Here
[/QUOTE]
And here:
www.okanagangirlz.com/store/[*4]
note: i took it one step futher, created a /store/ folder, renamed store.php to index.php and then edited that index.php and changed all references of store.php to index.php. clear as mud?
Just my own lil thing. I like /store/ rather than store.php
Re:CafePress script for GL
Posted on: 12/07/03 12:51pm
By: ScurvyDawg
I could not have pulled this off without your assistance destr0yr.
Thanks Much.
Re:CafePress script for GL
Posted on: 12/07/03 01:30pm
By: destr0yr
just make sure you tell me if you're ever comin to kt0wn. be sure to go for a (few) cerveza fría.
Re:CafePress script for GL
Posted on: 12/07/03 01:35pm
By: jager
Awesome job guys. I installed it and looks great.
One minor bug/note is that if the cafepress store has been "customized" to include a logo or introduction text, it looks like the script gets confused and puts the entire store under the left menu... If you remove the logo and the custom text though, everything works fine.
Thanks a ton!
Re:CafePress script for GL
Posted on: 12/07/03 01:47pm
By: ScurvyDawg
Your correct Jager, leave all the customizing to GeekLog do not do any customizing through Cafepress as the code likes your cafepress shop to be plain jane so it will work with GL.
Re:CafePress script for GL
Posted on: 12/09/03 10:04am
By: paulmon
Just can't seem to get this to work. I'm running PHP 4.3.x and I've tested that fsockopen does work with the following code:
$fp = fsockopen ("www.spider.org", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
n";
} else {
fputs ($fp, "GET / HTTP/1.0rnHost: www.spider.orgrnrn");
while (!feof($fp)) {
echo fgets ($fp,128);
}
fclose ($fp);
}
This works fine. I'm running Geeklog as a FastCGI with the Zeus webserver. I've changed the lib-common.php path to my lib-common. I change the biggining of the script to:
global $storeid;
// include("cpstore.inc");
$storeid = "somc";
and changed:
$stores = 'somc';
At the end of the day no matter what I do I get a "Bad Gateway" error. Which usually means that php exited with some kind of weird error when the PHP code was sent to the PHP fastcgi runner. I have no problems with any other PHP code so I'm confused. My store URL is:
http://www2.somc.on.ca/store.php
My Cafepress URL is:
http://www.cafeshops.com/somc
Can anyone shed any light on this?
Cheers,
Paul
Re:CafePress script for GL
Posted on: 12/09/03 02:14pm
By: ScurvyDawg
I am at work right now, I will look into your question when I get home.
Re:CafePress script for GL
Posted on: 12/09/03 07:31pm
By: ScurvyDawg
[QUOTE BY= paulmon]
I change the biggining of the script to:
global $storeid;
// include("cpstore.inc");
$storeid = "somc";
and changed:
$stores = 'somc';
[/QUOTE]
Except for $stores = 'somc'; why did you make the other changes. None of the other changes you made were reccomended nor tested for.
[QUOTE BY= paulmon]
I change the biggining of the script to:
global $storeid;
// include("cpstore.inc");
$storeid = "somc";
[/QUOTE]
None of the above is required and is commented out in the code I submitted. I am sure. I also do not know about the whole run as a CGI deal either.
I did not reccommend those changes nor do I know why you would have made them. Send me your example let me see if I can get it going???
I'd say keep it simple. Change the path to lib-common and the stores variable. Otherwise do not change anything and keep your customizations within the cafepress store to a minimum.
Good Luck.
Re:CafePress script for GL
Posted on: 12/11/03 08:15am
By: paulmon
[QUOTE BY= ScurvyDawg] [QUOTE BY= paulmon]
Except for $stores = 'somc'; why did you make the other changes. None of the other changes you made were reccomended nor tested for.
[/QUOTE]
You are correct, I didn't notice the comments around that portion of the code because this:
#####CHANGE THIS NEXT LINE TO JIVE WITH YOUR SITE
##### the first field is all your store ids seperated by a comma
##### in the second field just change this to your website.
Was way more noticable than the comments.
I've fixed the above and still get the error. Seems to be something in this particular PHP script that the FastCGI version of PHP doesn't seems to like. Very bizzare as this is the first time this has happened.
I'm going to inquire with some of the PHP FastCGI maintainers and see if they see an issue.
Paul
Re:CafePress script for GL
Posted on: 12/11/03 08:42am
By: paulmon
Fixed, permission problem. Seem the archive of this script extracts store.php as 600 and not 664. This makes the FCGI version of PHP all messed up because the php process that runs as user "php" didn't have the permission to open it.
All fixed, now I just have to remove the extra pointless text in my store so the formatting doesn't get messed up.
Great little addon to GL, great work!
Paul
Re:CafePress script for GL
Posted on: 12/11/03 10:13am
By: ScurvyDawg
Very cool man, I see the issue your having with the formating. Just lose that store and open another one without any customization. It is that opening comment statement in the cafepress output thats breaking your formatting.
I'd just creat a new store with no customization at all and then add products to that store.
Good Luck.
Re:CafePress script for GL
Posted on: 12/11/03 01:37pm
By: Anonymous (paulmon)
I'll give that a try. Your script works well.
Destroyer - As for your suggestion on hosting, I'm on a dedicated server with 1TB of data access a month. Mine to do whatever I want with.
Thanks again.
Paul
Re:CafePress script for GL
Posted on: 12/12/03 07:27pm
By: destr0yr
[QUOTE BY= paulmon]
Destroyer - As for your suggestion on hosting, I'm on a dedicated server with 1TB of data access a month. Mine to do whatever I want with.
[/QUOTE]
Hook a brother up?
Re:CafePress script for GL
Posted on: 12/14/03 02:17pm
By: arthur
Tried the plugin, but I'm getting some weird formatting. I'm sure I've made some obvious mistake. Any suggestions on how to fix it. The link:
Shrednow Store[*5] . Note: The google ads on the right are not a Right Block. They are hard-coded into the rightblock.thtml file.
Re:CafePress script for GL
Posted on: 12/14/03 02:27pm
By: ScurvyDawg
Create another store under your username at cafepress and Do not customize it at all. Other than add items, do not add any other customization to it. That should resolve the issue, you see the cafepress formatting buggers up the GL themes.
Good Luck keep us posted on your progress.
Re:CafePress script for GL
Posted on: 12/14/03 06:12pm
By: destr0yr
Further to Scurvy's comment, try a store name that is working such as his or mine to see what the formatting looks like. My store name is "okanagangirlz".
Gookluck.
Re:CafePress script for GL
Posted on: 12/15/03 12:44am
By: arthur
The page works with your store names. Thanks for your help.
Question - I removed the customization from the stores I tried. Is that not enough? Am I going to have to remake any store I want to use with this plugin?
Re:CafePress script for GL
Posted on: 12/15/03 12:53am
By: ScurvyDawg
I had to remake my old stores. I am thinking if your store was from before cafepress made cafeshops the code is different.
Just create a new store without any customization and populate it with products, you get to use your usual image bucket.
Good Luck.
Re:CafePress script for GL
Posted on: 12/15/03 02:02am
By: arthur
Well, this gave me an opportunity to create some new products. I created a new Cafepress store and updated my
page[*6] . It worked. Thanks.
Re:CafePress script for GL
Posted on: 12/15/03 09:45am
By: ScurvyDawg
Looks great, glad it is working for you.
Re:CafePress script for GL
Posted on: 12/15/03 06:06pm
By: arthur
I tried displaying more than one Cafepress store this afternoon. Neither store is showing. Both stores are new, with no customization.
The lines from store.php that I edited look like this:
open_store(shrednow3,shrednow4sky, "http://www.shrednow.com/store.php");
$stores = 'shrednow3,shrednow4sky'; //EDIT THIS VARIABLE TO BE A LIST OF YOUR STORES
Any ideas?
I'm going to revert to showing the one store until we figure this out.
Thanks.
Re:CafePress script for GL
Posted on: 12/15/03 09:51pm
By: ScurvyDawg
Ok, the first variable should still be commented out so it does not count.
The $stores variable however looks correct. Here it what mine looks like, it is a multiple store shopping cart for cafepress. See if you can find a difference.
$stores = 'scurvyd,silentb'; //EDIT THIS VARIABLE TO BE A LIST OF YOUR STORES
Good luck
Re:CafePress script for GL
Posted on: 12/15/03 11:24pm
By: arthur
I used your line in my file, and no products came up. Perhaps it's an issue with php on my host?
Re:CafePress script for GL
Posted on: 12/16/03 12:02am
By: ScurvyDawg
Didn't work at all?
Thats strange? Umm if the rest of you site works I doubt it would be a server issue.
Check out the
ScurvyDawg[*1] store that line works there. How about you email me your script with your store names at scurvydawg.scurvydawg.com the middle dot of course is the @ symbol.
CafePress script for GL
Posted on: 01/25/04 08:29pm
By: Anonymous (DJDevon3)
I'm having trouble with my cafepress integration. As the suggestion in the script I deleted my store and created a new one because I thought that might be the problem. Still getting the same error.
Warning: main(cpstore.inc): failed to open stream: No such file or directory in /home/southflo/public_html/store.php on line 9
Warning: main(): Failed opening 'cpstore.inc' for inclusion (include_path='.:/usr/local/lib/php:/usr/lib/php') in /home/southflo/public_html/store.php on line 9
Fatal error: Call to undefined function: open_store() in /home/southflo/public_html/store.php on line 14
Any help would be great.
CafePress script for GL
Posted on: 01/25/04 08:31pm
By: jager
Did you check the permissions on the files? That may be a possible culprit.
CafePress script for GL
Posted on: 01/25/04 08:39pm
By: Anonymous (DJDevon3)
tried everything up to 777. still no go.
Hmmm seems that the forum is taking out a lot of code...for security i guess. so if you want me to email u an attachment i can do that.
CafePress script for GL
Posted on: 01/25/04 08:47pm
By: jager
[QUOTE BY= DJDevon3] tried everything up to 777. still no go.
Hmmm seems that the forum is taking out a lot of code...for security i guess. so if you want me to email u an attachment i can do that.[/QUOTE]
No need. When you paste code, just be sure to put the [.CODE.] and [./CODE.] around it...minus the periods, of course.
I'd still double check your permissions before doing anything though...
CafePress script for GL
Posted on: 02/10/04 02:50am
By: anuenue
Has anyone run into a problem with not being able to open the socket? fopensocket is returning false, but the error code is 0. According to the php documentation the error occurred prior to the connect.
Any ideas?
CafePress script for GL
Posted on: 02/17/04 05:28pm
By: HMUSN
Hi, I must admit that I am a compleat newbie when it comes to all this stuff. So I am begging for some help to set up the HTML tags on this script. And yes its ok to talk to me like a 2 year old. I deserve it for being so dumb. Thanks for any help your willing to give.
Thanks for your time!
CafePress script for GL
Posted on: 02/17/04 07:24pm
By: ScurvyDawg
Hey there
I think the script is not designed to work as a static page so I doubt it will work that way as all the paths will be buggered up.
Just place the file in your public_html folder and be sure to open the store.php file in a text editor and edit the path the lib-common.
Once you have edited the path to lib-common then edit the stores to reflect the name of your CafePress store in the same file.
Now you can call to the store with a link like www.yoursitename.com/store.php and that's it.
I hope that helps
ScurvyDawg
CafePress script for GL
Posted on: 02/18/04 03:45pm
By: HMUSN
YEAH!! So I am not as dumb as I thought. Here is what happened to me. I was so exsited about the new verson of geeklog I totaly did not even think of that messing it up. But thats what it was. I went to the current verson and it worked fine. THANKS ScurvyDawg! Your Insainly Smart!
CafePress script for GL
Posted on: 03/28/04 05:39am
By: brindy
hey doods - i like this script, and it obviously works so i must be doing something dumb, but it's just showing all the items above the main gl page, check it out:
http://www.grrs.org.uk/store.php
i haven't got any customization on the store other than just adding the items that are there.
what am i doing wrong?
thanks in advance!
CafePress script for GL
Posted on: 03/28/04 07:41am
By: brindy
[QUOTE BY= brindy] hey doods - i like this script, and it obviously works so i must be doing something dumb, but it's just showing all the items above the main gl page, check it out:
http://www.grrs.org.uk/store.php
i haven't got any customization on the store other than just adding the items that are there.
what am i doing wrong?
thanks in advance![/QUOTE]
hey, i got it working but i had to edit the script. the script was assigning COM_site_header() and COM_site_footer() to a display variable, but the rest of the script was just using echo. i changed the assignment to the display variable to echo as well and it works fine:
at the top of the script...
$display = COM_siteHeader();
// becomes...
echo COM_siteHeader();
// and likewise for the footer.
i'm using gl 1.3.9 i don't know if that's got anything to do with it?
cheers,
brindy
CafePress script for GL with Premium Stores
Posted on: 03/31/04 05:04pm
By: ScottMcW
Hi all,
I'm using the CafePress script at http://www.type34.org/store.php and it's GREAT. Just wanted to know if anyone's using this with a CP Premium Store? Is there any reason why it shouldn't work? I'm eventually going to upgrade to that and hope that the script works just as well then!
Thanks all!
ScottMcW
www.type34.org
CafePress script for GL
Posted on: 04/07/04 12:07pm
By: ScottMcW
Ok ok...I'm slow this week, must be the time change. It only took me a week to figure out that since the Premium stores give you full control over the HTML, you don't really NEED the script.
Duh.
Ok, continue on now...I'll catch up eventually!
ScottMcW
www.type34.org
CafePress script for GL
Posted on: 04/19/04 02:02pm
By: ScurvyDawg
It is so cool you are having success with the script.
CafePress script for GL
Posted on: 12/01/04 03:07pm
By: destr0yr
cafepress added "Additional Photo's"... If you want them to work, add the following to your store.php around line 131 with all teh other preg_replace's:
$itemdetail = preg_replace("//content/products/productcenter//", "http://www.cafepress.com/content/products/productcenter/", $itemdetail);
CafePress script for GL
Posted on: 12/03/04 12:31pm
By: jhackwith
[QUOTE BY= destr0yr] cafepress added "Additional Photo's"... If you want them to work, add the following to your store.php around line 131 with all teh other preg_replace's:
$itemdetail = preg_replace("//content/products/productcenter//", "http://www.cafepress.com/content/products/productcenter/", $itemdetail);
[/QUOTE]
I tried to implement this and get the following error upon clicking on an item:
Warning: Unknown modifier 'c' in /home/.halima/jasonhackwith/intotheflame.com/store.php on line 131
Any ideas?
CafePress script for GL
Posted on: 12/04/04 10:36pm
By: destr0yr
[QUOTE BY= jhackwith]
I tried to implement this and get the following error upon clicking on an item:
Warning: Unknown modifier 'c' in /home/.halima/jasonhackwith/intotheflame.com/store.php on line 131
Any ideas?[/QUOTE]
Try wgetting http://www.okanagangirlz.com/store.txt and rename it to store.php.
CafePress script for GL
Posted on: 12/05/04 01:00am
By: jhackwith
[QUOTE BY= destr0yr]
Try wgetting http://www.okanagangirlz.com/store.txt and rename it to store.php.[/QUOTE]
Beautiful. Works great! See it at
http://www.intotheflame.com/store.php[*7] .
CafePress script for GL
Posted on: 12/09/04 05:02am
By: Anonymous (offsuit.com)
I just wanted to say, this hack is AWESOME!
And yeah, I had to fix the additional photo thingy, I was gonna say something, but looks like you guys are already on it.
--Nate
www.offsuit.com/store.php
P.S. - The only thing i can think of now is some way to put a featured product on the homepage, to let people know I have a store..
CafePress script for GL
Posted on: 12/09/04 09:44am
By: ScurvyDawg
There is block code to post a banner from CP on your site but if for some odd reason did not see it.
<br>
<center>
<a href="http://www.scurvydawg.com/store/cafe_store.php">
<img src="http://www.cafepress.com/cp/banners/promo_120x60_01.gif" width="120" height="60" alt="Support This Site" border="0">
</a>
<br>
<a href="http://www.cafepress.com/cp/info/storeref.aspx?refby=scurvyd" target="_blank">Get your very own online store.</a>
</center>
Of course you will have to edit the paths to suit you but check that out.
I will post a corrected store.php sometime over the next week.
CafePress script for GL
Posted on: 01/04/05 04:46pm
By: Anonymous (Daniel)
hey scurvy,
just wondering if there's an updated file for this? the link to the 1.3.9 integration file doesn't seem to work anymore.
thanks!
CafePress script for GL
Posted on: 01/04/05 05:25pm
By: ScurvyDawg
Ahhhhh
OK I will post a new one when I get home tonight.
I moved to a new server account and that must be one of the files I did not move.
I will post here when I am done.
Cheers
SD
CafePress script for GL
Posted on: 01/22/05 08:27pm
By: samstone
I see Dest0yer has a random product block, in place of the CafePress promo gif file. I wonder how he does that.
Sam
CafePress script for GL
Posted on: 01/22/05 11:09pm
By: ScurvyDawg
He and I did that using the
www.notonebit.com[*8] random item script
I am not currently using the basic store free script but he still is so can still use that block.
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.
CafePress script for GL
Posted on: 01/23/05 04:13am
By: destr0yr
[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.
[/QUOTE]
I guess somebody would just have to contact me and ask..
Drop the following into your /path/to/geeklog/system/lib-custom.php:
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.
Create a new phpblock with teh following info:
Block Title: Whatever you want
Block Name: again, whatever you want, make it unique
Block Type: PHP Block
Block Function: phpblock_randshop
Save it, position it, and you're set.
CafePress script for GL
Posted on: 01/23/05 10:32am
By: samstone
Thanks a lot!
Sam
CafePress script for GL
Posted on: 01/24/05 12:37pm
By: ScurvyDawg
CafePress script for GL
Posted on: 02/16/05 07:22pm
By: newblogger
Whenever I add the before mentioned function to my lib-common.php i lose my site, basically every page just turns white with no info. Also when attempting to add just the store.php to my public_html directory, changing just the store name i get the store.php coming up as just a white page also. no products or page blocks for that matter. any help would be greatly appreciated.
CafePress script for GL
Posted on: 02/16/05 07:47pm
By: ScurvyDawg
If you change the name of the script you have to change the references to store.php to whatever you named it in the store.php file, otherwise you get a blank page.
In regard to adding something to lib-common I do not see anyone who said to do so. Read the instructions again maybe you mean lib-custom??
CafePress script for GL
Posted on: 02/16/05 08:37pm
By: newblogger
i didn't change the name of the store.php i meant in the file store.php i changed it to my store 'virginia_slims' and i mistyped it is lib-custom.php i was changing, but like i said same results nothing is showing up
CafePress script for GL
Posted on: 02/18/05 12:02pm
By: newblogger
thank you for your help scurvy. the store.php is working finally. On to the other part of my original post, whenever i include the code for the random shop into my lib-custom.php, i get nothing but a white page for my entire site. any help on this matter?
CafePress script for GL
Posted on: 02/18/05 01:19pm
By: ScurvyDawg
Post your code for review here and be sure to use the CODE button in the forum so it is displayed correctly and not filtered out.
CafePress script for GL
Posted on: 02/20/05 06:16pm
By: newblogger
Ok thanks everyone for all your help sorry it has taken so long for me to get back, it has been a very tiring week. Posted below is an excerpt from my lib-custom.php that is not working. it has the last two entries working. daily dilbert, and then the rand_shop which is not. please advise. you can see my page
here[*10] as of right now i do not have the rand_shop code in my lib-custom as it cause my page to go blank. This is the version i replace my current lib-custom with, that causes the error. Ok here goes.
*/
/* Geeklog Block to retrieve the Daily Dilbert Comic
* Created by Blaine Lang
* Jan 13 2005
* www.portalparts.com
*/
function phpblock_dailydilbert() {
global $_CONF;
/* Create a unique name for the Daily Dilbert comic file */
$dilbert_todayfile = 'images/comics/dilbert'. date('Ymd') . '.gif';
$file = "{$_CONF['path_html']}$dilbert_todayfile";
/* Check if today's Dilbert comic already exists - if not retrieve it and create the image */
if (!file_exists($file)) {
/* Setup the Web Service Client */
include ($_CONF['path_system'] .'nusoap.php');
$wsdl = "http://www.esynaps.com/WebServices/DailyDilbert.asmx?WSDL";
$client = new soapclient( $wsdl,"true");
/* Call the Web Service and decode the base64 contents back to a GIF file */
$image = base64_decode($client->call('DailyDilbertImage', ''));
/* Now write the raw image and create the image file */
$fp = fopen("{$_CONF['path_html']}$dilbert_todayfile",'w');
fwrite($fp,$image);
fclose($fp);
}
$imageurl = "{$_CONF['site_url']}/$dilbert_todayfile";
return ("<a href=\"$imageurl\"><img src=\"$imageurl\" width=\"180\" border=\"0\"></a>");
}
function phpblock_randshop() {
global $_CONF;
// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '<!-- ### Items ### -->';
$end = '<!-- ### end of ITEMS ### -->';
$stores = 'virginia_slims';
$url = 'http://www.cafepress.com/' . $stores;
$itemfile = '/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
if (eregi("<td colspan=3>",$line)) {unset ($line);}
if (eregi("<tr>",$line)) {unset ($line);}
$line = ereg_replace("<a href="","<a href="http://www.whatmenwant.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:
$theitem = '<div align="center">' . $item . '';
$theitem .= '<a href="' . $_CONF['site_url'] . '/store.php"><strong>More Products</strong></a></div>';
return $theitem;
}
}
?>
CafePress script for GL
Posted on: 02/27/05 02:41am
By: newblogger
been a week and no answer, i guess i'll have to give up on this one.
CafePress script for GL
Posted on: 10/06/05 02:30pm
By: jetshack
very neat...
I've got no real use for it, but might come in handy later, who knows!
regardless... quick and easy setup and worked right out of the er... box?