[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] Serving non-html files with minivend (or: software payloads)
----- Original Message -----
From: Daniel Ceregatti <daniel@digitalsavant.com>
To: <minivend-users@minivend.com>
Cc: <scrumper@earthling.net>
Sent: Tuesday, November 16, 1999 6:29 PM
Subject: Re: [mv] Serving non-html files with minivend (or: software
payloads)
> Cameron,
>
> Sounds like normal cgi http header (Content -type: text/html) is already
being sent to
> the browser beforehand, otherwise it'd see the Content-type:
application/zip and just
> download the file. I wonder if there's a facility in minivend to make it
NOT send the
> http header in a particular instance.
I wonder the same thing myself. I figure this to be the cause also, and
have been scouring the docs and newsgroup for an answer but have found
nothing as yet.
>
> I'm interested in how you managed to create the download store, as I've
been put in charge of creating such a site. The minivend docs state that it
should be a simple thing to setup, but I have not seen any examples, and a
clear way to do this eludes me.
>
> Can you please let me know how this works out? Better yet, any chance of
seeing your code? :)
>
As you wish. Here's the code, as requested. I have a few comments at the
end regarding further development of the idea.
Code for payload is actually very simple. Consists of two chunks of code,
and a field for each product in the database called "payload" which gives
the filename of the relevant payload. If no payload, field is of course
left blank. Here's the first code segment, which would be included in the
receipt.html page, to be displayed after a successful order:
[item-list]
[if-field payload]
[set name="[item-code]Payload" interpolate=1][item-field payload][/set]
[page href="goods" arg="[item-code]"]Download [item-description][/page]
: [scratch name="[item-code]Payload"]<br>
[/if-field]
[/item-list]
This goes through each item in the basket and sets a "payload code" for it
if appropriate. It also creates a download link. Note that both these only
happen if the payload field in the database has a value in it.
Here's the second chunk of code. This is the file that the link in the
first chunk points to. In this case, it is named goods.html as specified in
the previous chunk. Here it is in its entirety:
[file name="payloads/[scratch name='[data session arg]Payload']"]
Note that this will evaluate to the filename specified in the "payload"
field for the item. Here is an example, in case it's not clear:
First chunk of code, executed for item PROD01, which has a "payload" of
prod1.exe, will evaluate to:
[set PROD01Payload]prod1.exe[/set]
[page goods PROD01]Download Product Number One[/page]
The second chunk of code (the page linked to in the above section) will
evaluate to:
[file name="payloads/[scratch PROD01Payload]"]
or, ultimately:
[file products/prod1.exe]
That's the basics. It works almost as intended, with the notable problem
being that the browser displays the target file as if it were html.
Obviously, once it is working properly the second piece of code should be
put in an [if] so that if the user's session has expired etc, a suitable
error message can be displayed.
Another possible implementation would be to keep a database of session tags
that have rights to certain files. You could include a time stamp in each
database entry, to make the rights expire after a certain time (two weeks,
for example). The first chunk of code would be expanded to create the
database entry, and the second chunk of code would be modified to include a
check for the same entry in the database.
I hope this helps you in some way, and I would be quite interested in
anything you come up with as an extension of this. Anyway, that's it. Good
luck.
===============================
Pounding away on my keyboard
in the dark.
Cameron
-------------------------------
email: scrumper@earthling.net
ICQ: 13571506
===============================