marty.net 1001 Postcards Love Love Love Meep Meep ZenZodiac DailyQuotation

YOU ARE HERE:
How to embed cpshop in a PHP page

HOME

CPSHOP|

|

|

EMAIL MARTY
  marty.net message board
  « How to embed cpshop in a PHP page »
Welcome, Guest. Please Login or Register.
12/11/17 at 13:07:30
Home Help Search Login Register
   marty.net message board
   About cpshop
   Tutorials
   How to embed cpshop in a PHP page
(Moderator: Marty)
Pages: « 1 2 3 4 5 6 7 » Reply Notify of replies Send the topic Print 
   Author  Topic: How to embed cpshop in a PHP page  (Read 64344 times)
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #15 on: 11/19/03 at 10:32:36 »
Reply with quote Modify message

The idea is that cpshop can be run from the command line.

When it's run from the command line, it accepts 3 arguments:
- the URL of the PHP page it's being run from (so cpshop can generate links)
- the URL of cpshop.cgi itself (used for popup windows, javascript links, etc.)
- the querystring of the current page, URL-encoded (so it knows what products to show, etc.)

And then, run from the command line, it prints out the results to standard output.  If you capture those results as a variable ($str in the example), then you can manipulate those results, and then print them to the page.
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
david@zatz.com
White Dragon
**

Posts: 11



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #16 on: 11/19/03 at 11:45:25 »
Reply with quote Modify message

Very cool! Now that makes sense. Not sure if my tool can do a command line exec, but there may be other ways....

So "the URL of the PHP page it's being run from (so cpshop can generate links)" theoretically could be the URL of the calling page, regardless of PHP, right?

Stay tuned, I'll let you know what I turn up!
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #17 on: 11/19/03 at 11:47:20 »
Reply with quote Modify message

So "the URL of the PHP page it's being run from (so cpshop can generate links)" theoretically could be the URL of the calling page, regardless of PHP, right?

Right.
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
david@zatz.com
White Dragon
**

Posts: 11



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #18 on: 11/19/03 at 11:49:10 »
Reply with quote Modify message

Damn! 2 minutes to a reply. Could you possibly be any more responsive?

I'm impressed. Also, thanks for being open to my slightly weird development desires.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #19 on: 11/19/03 at 11:53:06 »
Reply with quote Modify message

Actually, it's not weird at all.  With the proliferation of new languages, markups, etc. out there, it makes sense to make things flexible enough to work with anything, which is essentially what I was going for when I added the command line support.

Let me know if you have any other questions.
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
david@zatz.com
White Dragon
**

Posts: 11



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #20 on: 12/05/03 at 22:43:34 »
Reply with quote Modify message

OK, finally got some of the other stuff figured out. Here's where we're at:

I have a content management system (not PHP) running on a box different from where Apache, Perl, and PHP are located (and where CPSHOP is).

In the CMS page, I do an include that looks like this:


Code:
{tcp.examples.httpGet("linux1.zatz.com","/cpshop/cpshop.php",80)}


When it calls this:


Code:
<?php
$qs = urlencode($HTTP_SERVER_VARS['QUERY_STRING']);
$str = `C:\var\www\cgi-bin\cpshopManila\cpshop.pl http://linux1.zatz.com/cpshop/cpshop.php http://linux1.zatz.com/cgi-bin/cpshopManila/cpshop.pl $qs`;
echo $str;
?>


It'll display the first page correctly, but won't navigate right. If I change the third param to point to my CMS's page, as in this:


Code:
<?php
$qs = urlencode($HTTP_SERVER_VARS['QUERY_STRING']);
$str = `C:\var\www\cgi-bin\cpshopManila\cpshop.pl http://linux1.zatz.com/cpshop/cpshop.php http://manila.zatz.com/DubyaWatch/stories/storyReader$29 $qs`;
echo $str;
?>


It complains there's no config file (which makes sense, because "manila.zatz.com" is a different server).

Any idea how I can get around the fact that the cgi expects the config file to be derivable from that URL?

Thanks,
David

PS: Please ignore the DubyaWatch thing. It's not where the store's ending up, just an unused CMS page we tinkered with way back in the day.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #21 on: 12/07/03 at 01:33:10 »
Reply with quote Modify message

Wow.  You've managed to extend the content chain one step further.

The content starts at CafePress, where the original pages lie.  Then cpshop grabs those pages, and processes them in perl.  For those that use php, php issues command line calls to cpshop, grabbing the cpshop-processed pages, and displaying them.  Now you've got another server calling the php pages, and grabbing their output.

It's enough to make me dizzy.

I'd explain the problem itself, but since I'm tired from walking a dozen miles of shopping mall, and I've already rambled, I'll get right to the point.

I think when you do this call:


Code:
{tcp.examples.httpGet("linux1.zatz.com","/cpshop/cpshop.php",80)}


You need to include the query string in your request; if you don't, cpshop doesn't know what to do next.  Now, I know nothing about Manila, but I'd guess you'd need to do something like this:


Code:
{tcp.examples.httpGet("linux1.zatz.com","/cpshop/cpshop.php?" + pta^.searchArgs,80)}


I'm not sure if pta^.searchArgs is still URL-encoded, but it should be.

And you'd want to do that in conjunction with the first example of php code you had:


Code:
<?php
$qs = urlencode($HTTP_SERVER_VARS['QUERY_STRING']);
$str = `C:\var\www\cgi-bin\cpshopManila\cpshop.pl http://linux1.zatz.com/cpshop/cpshop.php http://linux1.zatz.com/cgi-bin/cpshopManila/cpshop.pl $qs`;
echo $str;
?>
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
david@zatz.com
White Dragon
**

Posts: 11



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #22 on: 12/09/03 at 14:45:00 »
Reply with quote Modify message

Yeah, I know. It's perverse. I'm using Manila to call PHP to call Perl (which is then front-ending Cafe Press). Sick!

Anyway, I've got much of this uber-hack working, except it generates URLS like:


Code:
http://manila.zatz.com/DubyaWatch/stories/storyReader$29/zatz.186833?target=prod&page=1 &trail=zatz%7EStandard%20Store%7E1&st=ZATZ%20Logo%20Merchandise&p=zatz.1852298


My Manila routine is getting tripped up by the "zatz.186833" before the parameters question mark, when it probably should be in the params table, after the question mark.

In other words, I should be using "http://manila.zatz.com/DubyaWatch/stories/storyReader$29?.." not "http://manila.zatz.com/DubyaWatch/stories/storyReader$29/zatz.186833?...".

Any ideas? By the way, I'd understand if you just don't want to deal with this perversion of your code. But if you're willing to play along, it might be useful to me.
« Last Edit: 03/22/04 at 17:14:18 by Marty » Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #23 on: 12/09/03 at 16:18:54 »
Reply with quote Modify message

Try setting "use clean URLS" in the cpshop admin program to "use query string".  That should fix it.
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
david@zatz.com
White Dragon
**

Posts: 11



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #24 on: 12/10/03 at 05:48:11 »
Reply with quote Modify message

OK, I think I got the sumnabish to actually work! For those who relish perversity, here's the chain:

CafePress
--> cpshop (Perl)
----> cpshop PHP interface
------> ZENPRESS (my code, which lives in..)
--------> Manila (a CMS, which lives in...)
----------> Frontier
<--------- and back for ordering.

I know, it's wacky, but it seems to work. Now I need to do UI 'n stuff.

Marty, you're a champ! Thanks.
Logged
nolageek
Guest

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #25 on: 02/08/04 at 20:20:29 »
Reply with quote Modify message

I'm still having problems with this.  The menu appears fine, but when I select one of the shops, I just get the menu again.  Here's my php file:



Code:
<?php
$qs = urlencode($HTTP_SERVER_VARS['QUERY_STRING']);
$str = `/home/virtual/site60/fst/var/www/cgi-bin/cpshop/cpshop.cgi http://www.noleftturns.com/vincent/store.php http://www.noleftturns.com/cgi-bin/cpshop/cpshop.cgi  qs`;
echo $str;
?>
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #26 on: 02/08/04 at 23:17:41 »
Reply with quote Modify message

Try changing the "Use Clean Store URLs" setting in the cpshop admin program to "use query strings with store URLs (with a "?store=")".  That should fix it.
« Last Edit: 02/08/04 at 23:21:18 by Marty » Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
James
Green Dragon
*

Posts: 9



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #27 on: 03/22/04 at 09:45:09 »
Reply with quote Modify message

FYI:  I was scratching my head when I tried this and it didn't work, I kept getting this message when I tried to click on a link:

Content-Type: text/plain /store.php The configuration file (store.php.config) has not been generated. Please run the administration script before proceeding.

(Note-I renamed the script store.cgi) After following all the ideas in the above posts, I looked a little more closely I realized that while I do have a store.cgi.config, I did not have a store.php.config--Copying the original to the php name solved the problem.  I'm Not sure how to change the variable so that I don't have to copy the file everytime I make modifications to the configuration though.
Logged
Marty
Administrator Dragon
*****

Gender: male
Posts: a whole lot



That's me. :)
   

WWW E-Mail
Re: How to embed cpshop in a PHP page
« Reply #28 on: 03/22/04 at 17:17:23 »
Reply with quote Modify message

I've never seen that particular error pop-up with this configuration.  php calls cpshop from the command line, and should realize that.  

What php include code are you using when calling cpshop?
Logged

--
Regards,
Marty·.¸¸.·´¯`·.¸¸.-> marty@marty.net
James
Green Dragon
*

Posts: 9



Go Scots!
   

E-Mail
Re: How to embed cpshop in a PHP page
« Reply #29 on: 03/22/04 at 17:47:50 »
Reply with quote Modify message

I'm using the following:

$qs = urlencode($HTTP_SERVER_VARS['QUERY_STRING']);
$str = `/usr/local/psa/home/vhosts/wwovf.com/cgi-bin/store/cpshop.cgi http://www.wwovf.com/store.php http://www.wwovf.com/cgi-bin/store/cpshop.cgi $qs`;
echo $str;

For some reason it's requiring me to use the two separate config files, however it actually works out well, as my main page (/store.php) uses the original and all the other pages use the other one, so I have the 2 columns I wanted on the main page and 3 in the products....  
Logged
Pages: « 1 2 3 4 5 6 7 » Reply Notify of replies Send the topic Print 
Jump to:


marty.net message board (http://www.marty.net/cgi/marty/board/messageboard)

Powered by YaBB 1 Gold - Release (Yet Another Bulletin Board)
Copyright © 2000-2001, X-Null. All Rights Reserved.