[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] softgoods
At 07:03 PM 02/27/2002 -0500, you wrote:
>Quoting Paul Jordan (paul@gishnetwork.com):
> > Is anyone out the an expert on IC regarding downloadable goods. Our
> store is
> > fully functional, and you can shop, purchase and download goods, (with the
> > test CC of course). A friend and I have been talking and he has been saying
> > I may want to change my delivery method. He said IC may give you problems
> > when multiple people start buying/downloading these .zip files.
>
>This is true.
>
>If you expect to sell lots of softgoods, the best thing to do is make
>your enabling procedure provide a symlinked directory for a separate
>HTTP download.
>
>It can be as simple as:
>
>UserTag enable-download Order resource
>UserTag enable-download addAttr
>UserTag enable-download Routine <<EOR
>sub {
> my ($resource, $opt) = @_;
>
> my $docroot = $opt->{document_root} || $::Variable->{DOCROOT};
> my $dl_dir = $opt->{base_dir} || 'tmp_download';
> my $server = $opt->{server} || $::Variable->{SERVER_NAME};
>
> ## Routine comes from Vend::Util
> ## We will use session ID, but this would make totally random
> #my $random = random_string();
>
> my $random = $Vend::Session->{id};
>
> require File::Path;
>
> my $dir = "$docroot/$dl_dir/$random";
>
> if(-d $dir) {
> # Must have been made previously
> }
> elsif ( File::Path::mkpath($dir) ) {
> ## Need to ensure readable for HTTP download
> chmod 0755, $dir;
> }
> else {
> logError("Unable to make user download directory %s", $dir);
> return undef;
> }
>
> # Routine comes from Vend::Util
> unless ( file_name_is_absolute($resource) ) {
> $resource = "$Vend::Cfg->{VendRoot}/$resource";
> }
>
> # Get the base file name
> my $filebase = $resource;
> $filebase =~ s,.*/,,;
>
> ## Now do the symlink
> symlink $resource, "$dir/$filebase"
> or do {
> logError("Unable to symlink %s to %s", $resource,
> $dir);
> return undef;
> };
>
> ## Return the URL of the now-symlinked resource
> return "http://$server/$dl_dir/$random/$filebase";
>}
>EOR
>
>This should be accompanied by a cron job which runs every half hour
>or so:
>
> ## Wherever that temporary base is
> BASEDIR=/var/www/html/tmp_download
> find $BASEDIR -type l -mmin +60 -exec rm '{}' ';'
> find $BASEDIR -type d -depth -mindepth 1 -empty -exec rmdir '{}' ';'
>
>--
>Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH 45013
>phone +1.513.523.7621 <mheins@redhat.com>
Very cool. One big gotcha to watch out for: make sure that Apache's auto
Indexes feature is disabled for the top-level download directory
('tmp_download') in this example. Otherwise people will be able to browse
through any subdirectories therein and grab whatever files they might find.
- Ed L>
===============================================================
New Media E.M.S. Software Solutions for Business
463 Main St., Suite D eCommerce | Consulting | Hosting
Placerville, CA 95667 edl@newmediaems.com
(530) 622-9421 http://www.newmediaems.com
(866) 519-4680 Toll-Free (530) 622-9426 Fax
===============================================================
- References:
- [ic] softgoods
- From: interchange-users@interchange.redhat.com (Paul Jordan)
- [ic] Wish list
- From: interchange-users@interchange.redhat.com (Jerry)
- [ic] softgoods
- From: interchange-users@interchange.redhat.com (Mike Heins)