andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Anyone using this?
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box
View previous topic :: View next topic  
Author Message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Jun 27, 2003 3:18 am    Post subject: Anyone using this? Reply with quote

I'd love to know if anyone is using this script on their own website!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
John
Newbie


Joined: 14 Aug 2003
Posts: 4
Location: Los Angeles

PostPosted: Thu Aug 14, 2003 8:14 pm    Post subject: Re: Anyone using this? Reply with quote

amnuts wrote:
I'd love to know if anyone is using this script on their own website!

Andy


Crying or Very sad
I am using it untill today when they went down. Boy did it tear up the web site .

Warning: feof(): supplied argument is not a valid File-Handle resource in /usr/www/gear/class.cafepressbox.php on line 214

Warning: fgets(): supplied argument is not a valid File-Handle resource in /usr/www/gear/class.cafepressbox.php on line 216

I did not know what was going on so I went to the store site and found:

http://www.cafeshops.com/ErrorPage.aspx?aspxerrorpath=/index.aspx

Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>


So maybe an error dump or something would be cool. It keeped my page scrolling forever untill you hit stop on the browser. I guess a meg went by before I stopped it. Heck it was so fast I could not read it.

But great program!

Thanks
John
http://www.kqlz.org
Back to top
View user's profile Send private message Visit poster's website AIM Address
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Aug 15, 2003 3:07 am    Post subject: Re: Anyone using this? Reply with quote

Hi John, and welcome to the board!

John wrote:
amnuts wrote:
I'd love to know if anyone is using this script on their own website!

Andy


Crying or Very sad
I am using it untill today when they went down. Boy did it tear up the web site .


Ack!! I'm really sorry about this. Turned out that I didn't have a check in there to see if the file handle to the CafePress website was being created or not.

I've now updated the class and have posted it up for download. Thanks for letting me know!

John wrote:
So maybe an error dump or something would be cool. It keeped my page scrolling forever untill you hit stop on the browser. I guess a meg went by before I stopped it. Heck it was so fast I could not read it.


It should now just say 'could not connect' in the template, rather than give lots of errors!

Regards,

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
John
Newbie


Joined: 14 Aug 2003
Posts: 4
Location: Los Angeles

PostPosted: Fri Aug 15, 2003 4:47 am    Post subject: Re: Anyone using this? Reply with quote

Quote:
It should now just say 'could not connect' in the template, rather than give lots of errors!


Cool! Very Happy
Thanks for the help!

As soon as I make my first sale you will get a Paypal from me!

Great Product!

I'll make sure your web address is posted on my link page (when ever I get around to getting that done and posted). Wink

Thanks
John
http://www.kqlz.org
Back to top
View user's profile Send private message Visit poster's website AIM Address
gfxmonkey
Newbie


Joined: 21 Sep 2003
Posts: 3
Location: USA

PostPosted: Sun Sep 21, 2003 4:34 pm    Post subject: Problem with pulling products Reply with quote

Hello,

I really like the idea behind this class. I have been playing around with it, trying to get it to work. I am wondering if CafePress changed the way they display the products, as I cannot get anything to show up and I noticed the example page didn't have any products showing up either. I just see the no products found text, even though I know I am testing with store(s) that have items in them.

Any help appreciated Smile

- Daniel
Back to top
View user's profile Send private message
John
Newbie


Joined: 14 Aug 2003
Posts: 4
Location: Los Angeles

PostPosted: Sun Sep 21, 2003 6:52 pm    Post subject: Re: Problem with pulling products Reply with quote

gfxmonkey wrote:
Hello,

I really like the idea behind this class. I have been playing around with it, trying to get it to work. I am wondering if CafePress changed the way they display the products, as I cannot get anything to show up and I noticed the example page didn't have any products showing up either. I just see the no products found text, even though I know I am testing with store(s) that have items in them.

Any help appreciated Smile

- Daniel

I am using it and I just checked and it's working.
If you want to make sure you can see it on my site.
http://www.kqlz.org (Look down on the left side of the page)
I have not had a problem with this script since after my last post. It has been working great!

I hope this helps.
John
Back to top
View user's profile Send private message Visit poster's website AIM Address
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sun Sep 21, 2003 6:55 pm    Post subject: Reply with quote

Hey there, and welcome to the board!

Perhaps CafePress have made attempts to stop anything like this happening. I've tried debugging the script, and it seems to fail on the 'if ($fp = fopen("http://www.cafeshops.com/cp/store.aspx?s={$this->storeID}", 'r'))' line. This is the response I get from the server:

Code:
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Sun, 21 Sep 2003 23:33:03 GMT
Cache-Control: private
Content-Length:0


Okay, so I try to connect via just 'http://www.cafeshops.com/{$this->storeID}', and this is the response I get from the server:

Code:
<!-- request.rawurl: /error404.aspx?404;http://www.cafeshops.com/amnuts -->
<!-- request.path: /error404.aspx -->
<!-- request.url.host: www.cafeshops.com -->
<!-- URL: amnuts -->
<!-- path: amnuts -->
<!-- page:  -->
<!-- QueryString:  -->


So... a bit of a sod, really! I guess I could try something with sockets connecting to port 80? Could be a possibility....

You'd think CafePress would be only too happy to have people highlight their products on their websites, wouldn't you? Surely it only helps to draw people to CafePress (and those extras hits must look good to the investors!)

*sighs*

Andy


Last edited by amnuts on Thu Nov 06, 2003 5:14 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sun Sep 21, 2003 6:58 pm    Post subject: Re: Problem with pulling products Reply with quote

John wrote:
I am using it and I just checked and it's working.
If you want to make sure you can see it on my site.
http://www.kqlz.org (Look down on the left side of the page)
I have not had a problem with this script since after my last post. It has been working great!


Hmm.. I've tried and cannot get the product list. I'm using the free account - are you, John? I imagine it's still working for you because you have a cache file from before it went belly-up. If I were you, I'd back up that cache file so you don't loose it!!!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
aranjit
Newbie


Joined: 21 Sep 2003
Posts: 1

PostPosted: Sun Sep 21, 2003 8:02 pm    Post subject: used to work Reply with quote

I only noticed today, but the script doesn't seem to work anymore. It was working for at least a month with no problems. Is cafepress changing their policy on parsing their pages?
Back to top
View user's profile Send private message
gfxmonkey
Newbie


Joined: 21 Sep 2003
Posts: 3
Location: USA

PostPosted: Sun Sep 21, 2003 8:15 pm    Post subject: CafePress policy? Reply with quote

I know for the past 6 months or so, cafepress had been changing their policy regarding off site hosted solutions to using their data. I would guess they changed things again, and it's somehow breaking things.

I found this post on the CafePress message boards: http://pub80.ezboard.com/fcafepressstoreownersforumfrm5.showMessage?topicID=447.topic

I really want the ability to work with the cafepress data off of their site, because it is so much more powerful/useful that way.

- Daniel
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sun Sep 21, 2003 8:25 pm    Post subject: Reply with quote

Hi there - welcome to the board!

It's not the parsing that that's caused the problem, but more over controlling the access to the pages.

HOWEVER, I have just got a solution working that will get around this problem, using a direct socket connection and sending a GET request. If everyone can give me till tomorrow evening, I can post up a new version of the script. However, I've been working on this problem since the first post went up tonight, and it's now 2:22am. I have a meeting with the bank manager tomorrow at 10am because I'm trying to get a mortgage to buy my first house... So I really need to get to sleep right now!!

You know.. Okay, quickly... This is something like the code should now go:

PHP:
<?php

    
function getProducts()
    {
        
$this->products = array();

        if (
$this->cacheTime && ((time() - @filemtime($this->cacheDir 'cache.' $this->storeID)) < $this->cacheTime))
        {
            
$this->products = @unserialize(@join('', @file($this->cacheDir 'cache.' $this->storeID)));
        }
        else
        {
            
// connect to the website
            
$reqheader "GET /cp/store.aspx?s={$this->storeID} HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: RandomProduct\r\n\r\n";
            
$socket = @fsockopen("www.cafeshops.com"80, &$errno, &$errstr);

            
// we can connect just fine
            
if ($socket)
            {
                
fputs($socket$reqheader);
                while (!
feof($socket))
                {
                    
$line fgets($socket4096);
                    
$line stripslashes($line);
                    
$matches = array();
                    if (
preg_match("/{$this->cpPattern}/i"$line$matches))
                    {
                        
// item # :: item desc :: directory :: image name :: item # :: item desc :: price dollar :: price cents
                        // e.g.
                        // 5956381 :: White T-Shirt :: 1 :: 5956381_F_store :: 5956381 :: White T-Shirt :: 14 :: 99
    
                        
$this->products[$matches[1]]['description'] = trim($matches[2]);
                        
$this->products[$matches[1]]['image'] = trim($matches[4]);
                        
$this->products[$matches[1]]['image_url'] = "http://storetn.cafepress.com/{$matches[3]}/" trim($matches[4]) . '.jpg';
                        
$this->products[$matches[1]]['price'] = "{$matches[7]}.{$matches[8]}";
                    }
                }
                
fclose($socket);
                if (
$this->cacheTime$this->saveCache();
            }
            
// there was a problem
            
else
            {
                return 
FALSE;
            }
        }
        return 
TRUE;
    }

?>


There... Replace your function with this and it should work just fine. Smile Tomorrow will see the new release.

G'Night!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sun Sep 21, 2003 8:28 pm    Post subject: Re: CafePress policy? Reply with quote

gfxmonkey wrote:
I know for the past 6 months or so, cafepress had been changing their policy regarding off site hosted solutions to using their data. I would guess they changed things again, and it's somehow breaking things.

I found this post on the CafePress message boards: http://pub80.ezboard.com/fcafepressstoreownersforumfrm5.showMessage?topicID=447.topic

I really want the ability to work with the cafepress data off of their site, because it is so much more powerful/useful that way.

- Daniel


Thankfully they're not saying you *can't* do it.. just that they wont *support* it (from how I read it, anyway.) So it doesn't look like we're breaking any rules/regulations here. Try out the fix I posted above and let me know if it works out for you (that goes for the rest of you, too! Smile )

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
gfxmonkey
Newbie


Joined: 21 Sep 2003
Posts: 3
Location: USA

PostPosted: Sun Sep 21, 2003 9:34 pm    Post subject: It works! Reply with quote

Hey thank you very much! It works great. Smile Very good job on the work around.

Definetly a great tool, and I can even get it to link to my off-site hosted store of cafepress stuff.

One nice feature/hack might be to take GD or Imagemagik and dynamically resize the cafepress thumbnails to something smaller. This would give us even greater flexibility in where we put this data. Of course, it would probably be good to cache the resized thumbs somewhere. I'm not greatest with php (more of a designer actually), but this is something that definetly intrigues me.

- Daniel
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Sep 22, 2003 2:21 am    Post subject: Re: It works! Reply with quote

gfxmonkey wrote:
One nice feature/hack might be to take GD or Imagemagik and dynamically resize the cafepress thumbnails to something smaller. This would give us even greater flexibility in where we put this data. Of course, it would probably be good to cache the resized thumbs somewhere. I'm not greatest with php (more of a designer actually), but this is something that definetly intrigues me.


Funny you mention this, because I thought of the same thing as I signed off last night! Perhaps I'll work something into it before I make the new release...

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
John
Newbie


Joined: 14 Aug 2003
Posts: 4
Location: Los Angeles

PostPosted: Mon Sep 22, 2003 4:04 am    Post subject: Re: Problem with pulling products Reply with quote

amnuts wrote:
John wrote:
I am using it and I just checked and it's working.
If you want to make sure you can see it on my site.
http://www.kqlz.org (Look down on the left side of the page)
I have not had a problem with this script since after my last post. It has been working great!


Hmm.. I've tried and cannot get the product list. I'm using the free account - are you, John? I imagine it's still working for you because you have a cache file from before it went belly-up. If I were you, I'd back up that cache file so you don't loose it!!!

Andy

Yes I am using the free account.
I just added more stuff tonight and it's working on 3 computers here and 2 of them have never been on the net before.
I am not sure on what going on.
I can see everything plus the new stuff I added.

John
Confused
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group