skip to Main Content

I have a website that let users download PDF files, I made a download limit 10 files per day for each user and I stored the numbers inside MySQL table under column named “downloads”.

Each day I use this command to set all values to 0 for all users:

update users set downloads = 0

I contact my web-host provider and they refused to give me super user privilege to make schedule for this column to reset itself each 24 hour.

Is there any other way to make little code in PHP to reset that column from outside or any other way to do that?

Update: I can not run cron job either!

2

Answers


  1. Store the last reset time in a file or the database and upon every new download request check if the last reset was 24h+ ago. If so, reset the download counter and update the time. That way you are not reliant on a background job.

    Alternatively you could set up a route (some URL to be called) that is periodically called from an external source (either your pc or some web service), and resets your download counters.

    Login or Signup to reply.
  2. Save in the database the date and the downloads number in the same field, every time you update this field ask if the date inside is today if not save today’s date and zero downloads for example your field will be:

    date_downloadsTimes
    03-02-2019_2

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search