2 replies
Hey
I'm not much of a programmer, but I'm trying to figure out how to limit the number of downloads of a particular file hosted on my servers.

So, if I wanted to send my list a free eBook which was available only for the first 500 people to hit the download link, how would I go about doing it?

Thanks a lot for your help, and your time.
Cheers,
Nathan.
#downloads #limiting
  • Profile picture of the author Mike Adams
    Get DLGuard, It will allow you to limit the number of DLs
    Signature
    P.S. If you found my post useful, please click the "Thanks" button below...
    {{ DiscussionBoard.errors[1870451].message }}
    • Profile picture of the author nzjav05
      The easy way of doing this is just buying DLGuard. (Especially if you don't know code).


      But if you do know the basics of coding, then here's a quick rundown of a simple way:

      - Create a new DB, in this database input two tables. One named "ip" and the other "download count".

      - In the IP table, all that we need to track is IP's, so that is all your going to add to the fields.
      - In the download count table, you only need to track the download count.

      ^ This is now going to track our visitors (so they can re-download) and also limit to 500.

      - In a php file, you will need the following:

      **connect to DB**
      **query both tables (ip table in an array & needs to select WHERE ip=$_SERVER['REMOTE_ADDR'])**

      if ($row['ip'] == '' && $row2['download_count'] < 501)
      {
      add ip to database and update download count by adding one to the total, and then you can download the file...
      }
      else if ($row['ip'] != '')
      {
      You can re-download the file....
      }
      else {
      We are sorry, but the 500 copies are gone...
      }


      ^ This script will only count the first 500 IP's, and then it won't add any more to DB.

      This is just a quick example, and I haven't tested anything or even given it a second thought (so probably some errors), but at least this can be a guide if your wanting to create a script yourself to do this.

      Also, this offers no protection for the true location of your file. You can hide it with php, but that is a whole different story.


      Anyway I hope this helped as a broad example.
      {{ DiscussionBoard.errors[1871564].message }}

Trending Topics