close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Restricting possible downloads

Thread began 11/18/2010 4:59 am by henrik.schlegel400884 | Last modified 1/03/2011 1:28 pm by henrik.schlegel400884 | 3160 views | 14 replies |

Henrik

Restricting possible downloads

Following "How to create a Download Center" I am now at the point to implement the download counter.

Is there a more detailed tutorial on how to achieve restricting the possible downloads through a number and an expiration time?

I am using the "Free Ecommerce MySQL Database".
Is there the necessary column for storing the download count already included or do I have to insert this column? In the orderdetails table?

And further:
How can I then achieve the restrictions -

a; through the numbers of possible downloads?
b; through an expiration time?

If somebody could help me on this -
that would be great!
:-)

Thanks!

Henrik

Sign in to reply to this post

Jason ByrnesWebAssist

no, there is not a more detailed tutorial for this.

first lets look at restricting number of downloads:

In the Orderdetail table, you will need to add a new column for the download count, set the default value to 0.

On the download_center.php page, you will need to add another condition to the where clause of the WADAorderdetails Recordset, lets say you want to limit the download to 5, and have named the download count column "downloadCount":
AND orderdetails.downloadCount <= 5

to update the counter, you will need to add an additional hidden form element to the download form, name it "prodID". Set it's value to use the ProductID column of the WADAorderdetails recordset.

Now in the Download file server behavior, check the option to update the download count.

Set the table to use the oredersetails table.

the key column to the DetailProductID.

Click the lightning bolt next to key column value and select the prodID hidden form element.

For the count Column select the downloadCount column.

You will want to make sure that the download file server behavior is before the WADAorderdetails recordset.


Now lets look at restriction by date:

Again you should add another column to the order details table for the expiration date.

at the time of order, you will need to calculate when the file download should expire, and update the store order details behavior to store the expiration date in that column.

you can then modify the WADAorderdetails recordset to ensure that the currant date is before the expiration date by adding another condition to the where clause.

AND orderdetails.expirationDate >= now()

Sign in to reply to this post

Henrik

Many Thanks, Jason!

I did the restriction by number of downloads.
It works ...

Just a question to the restriction by expiration date:
I understand the 1. and 3. part but have problems with the 2.

At the time of order how/where can I calculate the expiration date?
And how/where do I update the store order details behavior with the calculated exp. date?

I would like to set the expiration date 1 Month or lets say 31 days after the time of order.

Thanks again!

Sign in to reply to this post

Jason ByrnesWebAssist

You can calculate a date 31 days into the future using the following code:

php:
<?php echo(date("m/d/Y"mktime(000date("m"), date("d")+ 31date("Y")))); ?>




the store order details server behavior is on the confirm page.


edit the store order details behavior and set the value for the expiration date to use the code above.

Sign in to reply to this post

Henrik

The update of the database with the calculated expiration date doesn't work.
The value which appears in the database is 0000-00-00.

I edited the store order details behavior on the pp_confirm.php page and pasted the code above in the "Value" field of the expiration date column as type: text.

Also I added the where clause on the Wadaorderdetails recordset on the download_center.php page - like you suggested.

Strange was also one try I did changing your code to:

<?php echo(date("Y/m/d", mktime(0, 0, 0, date("Y"), date("m"), date("d")+ 31))); ?>

(Just wanted the sequence of numbers like it is in the order history!)

Then I got as calculated expiration date: 1970-01-01

Changed the code to how it was before, then I got again: 0000-00-00


Did I something wrong or is something wrong with the code?

Thank you for any help!

Sign in to reply to this post

Jason ByrnesWebAssist

a my sql date time column wants the date in yyyy-mm-dd format:
<?php echo(date("Y-m-d", mktime(0, 0, 0, date("m"), date("d")+ 31, date("Y")))); ?>

Sign in to reply to this post

Henrik

Now it is working ...

Thank You!

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Henrik

Counting Down possible?

Just another question regarding the download count. I think it would be more elegant to set it up that it counts down. One could name it "Downloads left (or remaining)" and let it count from 5 to 0.

How could this be achieved?

I guess the default value of the download count column would be set to 5. (?)

The where clause of the WADAorderdetails Recordset: AND orderdetails.downloadCount > 0 (?)

But how to set it up that it counts down?

I guess I have to change something in that Download File code: (right ?)

<?php
WA_DFP_SetupDownloadStatusStruct("WA_DownloadResult1");
if(($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)){
WA_DFP_DownloadFile("WA_DownloadResult1", "--removed--", "".((isset($_POST["hiddenField"]))?$_POST["hiddenField"]:"") ."", "[FileName]", 1, $database_mysql_sonic_magic, $mysql_sonic_magic, "orderdetails", "DetailProductID", "".((isset($_POST["prodID"]))?$_POST["prodID"]:"") ."", "downloadCount");
}
?>


Could someone give me an advice on this?
Thank you!
Henrik

Sign in to reply to this post

Jason ByrnesWebAssist

You dont need to change anything in the recordset, it how it stores the value in the table. Only change how it is displayed on the page.


the table will still store the incrementing value, but you can do simple math on the output that displays the downloads remaining:
<?php echo($row_RecordsetName['DownloadCount'] - 5); ?>

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...