My electric toothbrush seems to be running out of charge quicker and quicker but is it or am I just misremembering when I last charged it? This is the first world challenge that I set about to change with WDiL!
Introducing When Did I Last? (WDiL)
WDiL aims to help solve those sorts of problems by allowing you to record every time you do something and then see stats on things such as frequency and average interval.
While I have tried to make it very simple it still requires a bit of setup and hosting by you. As part of the simplicity it has no database (it uses a flat file with data held as a serialised array), few external libraries (only simple.css, datatables and smarty, just one Javascript function and a tiny bit of JQuery.
One final word of warning – this comes with absolutely no warranty whatsoever.
Getting Started
As implied above there are a few hoops that you have to jump through to get this working.
Hosting the app
You’ll need WDiL to be hosted on a public webserver somewhere. It is written in PHP, tested on version 8.1.29, requires no database and has been tested on Linux running Apache. Other configurations should work but may need some adjustment.
Get started by closing the repository:
git clone https://github.com/williamsdb/WDiL
You’ll now need to install Composer before you can proceed.
Other required actions
Next, you need to install the dependencies, create some required files and set the appropriate permissions. This is what I did but you may need to adjust depending on your flavour of OS:
php composer.phar require smarty/smarty
sudo mkdir templates_c
sudo chown apache:apache templates_c -R
sudo chcon -R -t httpd_sys_rw_content_t templates_c
sudo mv config_dummy.php config.php
sudo mkdir databases
sudo chown -R apache:apache databases
sudo chcon -R -t httpd_sys_rw_content_t databases
sudo touch logs.db
sudo touch users.db
sudo chown apache:apache *.db
sudo chcon -R -t httpd_sys_rw_content_t *.db
sudo chown apache:apache config.php
sudo chcon -R -t httpd_sys_rw_content_t config.php
Set-up
Now that you have the app installed you can configure it by editing config.php which looks like this:
<?php
// your timezone
define("TZ", "Europe/London");
// registration code
define("REGCODE", "");
// admin username
define("ADMIN", "");
// log calls
define("DEBUG", FALSE);
?>
There aren’t many options at this stage but they are:
- timezone – adjust as necessary
- registration code – WDiL is multi-tenanted so you might want to offer it to family & friends. Setting a code helps ensure that only they register
- admin username – when you login with this account you will see additional, administration, options. Put your username here
- log calls – debug tracing.
In use
When you load up WDiL you’ll be taken to the login page. Click the link below the form to go to the registration page where you can enter your details. Remember the registration code you entered above? Well, now you need it!
On successful registration, you will find an entry for your account in users.db and a <username>.db file in the database folder.
You can now create as many activities as you like and then “trigger” them when the activity occurs. Over time you will be able to see statistics regarding how often you carry out that activity, average interval between triggers and more.
Conclusion
This is just the beginning for WDiL. Next up will be a refresh of the UI to something, well, less ugly! I also want to be able to change the date and time on triggering so that’s coming too. You can keep up-to-date with all the changes by staring on Github.
One comment on “When Did I Last? (WDiL)”