How can I enhance my registration script?

As mentioned in the title, I am working on enhancing my initial script for the database registration code. Specifically, I would like to implement a feature where, upon logging into the database a specific date range is automatically created for a set period, such as 15 days, with a start date of 1-09-2023 and an end date of 15-09-2023.

Additionally, I would like to handle a scenario where a user attempts to change the date on their computer system to a date prior to 1-09-2023. In such a case, an error message should be displayed, and the database should be closed, except for access by the admin.
please find the below script.

If the file is hosted, you can use GetAsDate ( Get ( CurrentHostTimeStamp )) instead of Get ( CurrentDate ).
Or Get ( CurrentTimeUTCMilliseconds )

3 Likes

Indeed, the database will not be hosted. However, how can I prevent users from accessing my database for a date that is one or more days prior, given the circumstances described above in my situation?

If your database is not hosted, it means that the user has a physical access to the file.
Will it be encrypted?
If not, there’s no point in limiting access since anyone with a physical access to a file would be able to crack it.

Hi Saeed,

I will give you my thoughts here since it might also interest others.

I understand you have a startup script and a record in a table that the user can not access, where you save the allowed date interval. It also sounds as if the interval is set on the first opening of the database.

If this is so, we have a setup record that is hidden from the user, and we can now use it in different ways:

Demo

Fifteen days for your solution to run sounds short, so is it a demo? If so, maybe change from a date interval to time in hours. Instead of 15 days, give them 50 hours to check out your solution.

Add a start time field in the record.

Add a countdown field in the record.

Add a script that will run when the solution is closed.

Then, when the startup script runs, set the start time, and in the shutdown script, set the countdown field with time left. Using the countdown field, you can easily show it at startup to inform the user how much time they have left.

Date 1

I remember back in the last century when I set back the clock to cheat an end date, but that is not working anymore since that would impact so many other computer functions since everything is so complex and interconnected. (I am talking about a time before the internet compared to today).

Anyhow, a simple fix is the following:

Add a last date field in the record.

Add a script that will run when the solution is closed.

Then, when the shutdown script runs, set the current date, and the next time the startup script runs, check that the current date is ≥ the last date.

You can, of course, set the current date in the startup script, but if the user leaves your solution open over the night, it might be one day behind.

Date 2

Since everyone is connected to the internet at all times nowadays and there are a lot of things that won't work correctly on the computer if not, you can also use that to your advantage:

In the startup script, send a request to a "Current time API", and you will always have the correct time even if the clock in the computer is broken. I use the following free API that returns a JSON or .txt response that is easy to parse.

WorldTimeAPI

3 Likes

Every time you intervene, it feels like magic. I'll be exploring the last point, which is the API, as it's currently my challenge. Regarding specifics, the date and countdown functions are working perfectly for me.

1 Like