Running BOINC Tasks in my website updated! Scripts and tool updated

Running BOINC Tasks in my website updated! Scripts and tool updated

Repository:

https://github.com/moisespr123/BOINCToWeb

Hi everyone,

In the weekend, I worked to improve the BOINC Tasks section of my website:

BOINC Statistics Website Update 1

Instead of manually updating this page, I’ve updated the PHP files in charge of retrieving the tasks and showing it. This file was custom made and was not in the GitHub repo. Instead, the file that was in the repo was the one that looks like this:

BOINC Statistics Website Update 2

Because that one shows all of the tasks from all of the hosts, I made another PHP file to replicate the format I used in my website but instead of having to manually type each machine there, I made the php file use some functions and loops to retrieve the machines and tasks from the database. The result is the following:

BOINC Statistics Website Update 3
BOINC Statistics Website Update 4

Looks better, right?

Let’s take a look at the code:

First, I made a separate file called config.php to keep the MySQL details there. I’m also using a global mysqli object. Because of this change, I modified the original BOINC Tasks PHP script:

BOINC Statistics Website Update 5

After doing that, I wrote the next file, which I called boinc_tasks_per_machine.php:

BOINC Statistics Website Update 6

There’s 3 functions in this file:

BOINC Statistics Website Update 7

function printMachinesLinks($mysqli)

This function gets the machines from the MySQL database and it’s used to print the machine list, which is printed with a clickable link that goes to the machine table that shows the BOINC Tasks

function getTasksFromMachines($mysqli)

After getting and printing the machine list, we call this function which will then call the next function I’ll mention below.

function getTasksPerMachine($mysqli, $machine)

This function will get the BOINC tasks that a specific machine is running. It generates the table and prints the header as well.

Those are the functions. Next, we call them to print the neatly formatted document with these 2 lines:

printMachinesLinks($mysqli); 
getTasksFromMachines($mysqli);

The first one calls the printMachinesLinls($mysqli) function to print the machine list and the second line is the one that calls the function that generates the tables.

The software that populates the database:

BOINC Statistics Website Update 8

I also did some updates to this software. First, I made TruncateTables a function which will return True if it was successful truncating the table, and False if it wasn’t:

BOINC Statistics Website Update 9

Also, I added a NotifyIcon element to hide the software in the system tray and added a function to run the software when we pass the -s argument. This way, the software can be programmed for the Task Scheduler tool so it is launched in a minimized way and start retrieving the tasks:

BOINC Statistics Website Update 10

Then, I also made the Fetch button a Stop button. Clicking it after the software is running and is fetching the tasks will stop the process:

BOINC Statistics Website Update 11

Also, I refactored some code:

BOINC Statistics Website Update 12

And that’s it for the software changes. Basically I improved it in some ways. The page is now dinamically updated instead of manually updating which is a real plus for me. No more coding in the page! I just need to add and alter the machine list in the software and that’s it! The page will get updated with the machines listed in the software which it was able to connect and retrieve the tasks successfully.

Because the PHP files are very simple and straightforward, you can copy the file content into another page or add some styling. In my case, I integrated it with Drupal by making a PHP content page there.

PHP Files:

The PHP Files shown in this post can be found here.

Integration example:

You can see how the script looks integrated into WordPress here.

What next should I do with this? I’ve yet to know 🤔

Hope you like this!

Previous posts:

  1. Introductory post
  2. v1.1 changes
  3. v1.2 changes
Buy Me A Coffee
Thank you for visiting. You can now buy me a coffee!