
You can find an example of all this tip&tricks implementations into the Php Controller package.
The Php Controller package consists of the following folders and files:
Use php session variables to store, manage and share process data in your project
The suggested technique to browse between pages is to reload the same index.php page and passing the php variable $module, using the HTTP method GET.
The following code inside the file index.php is an example of a Php Controller menu, composed by four buttons which make load differents page modules as appropriate.
After, always into the file index.php, you need to develop a modular content in this way
In order to load a specific content (or also a specific php script) according to the required page.
NOTE - don't worry if you don't see any line like $module = $_GET['module']: this command is contained into the file ./script/init/indexRequirements.php, called into the page header.
To refresh a div content in your graphical interface, automatically every X milliseconds, consider to implement the following basis code inside the file ./scripts/custom/headers/headers.php
Using the php function echo you can send the javascript code to the client browser, which will require the new content to the server every refreshing clock. The value of this timing is stored into the session varable $_SESSION['statistics'], which is configured by editing the parameter statistics into the file ./scripts/custom/system/initData.ini. In this example, the function refreshStats() will update the content inside the divs with ID stats and status in the page index.php.
To complete the implementation you need to add and customize the following lines into the index.php file
Now consider to have a slider in your interface which sends to the server the new value for the variable $_SESSION['var1'], when the status of the slider is changed by user.

You can implement the previuos software architecture using and customizing the following code, which is contained into the file ./scripts/custom/work/ajaxRequest.php
As you can see, when the user changes the slider value, his browser calls the function changeValue(var, value), passing the name of the variable and its new value. These data are sent to the server via AJAX request, running the script ./scripts/custom/work/changeValue.php which acquires the updated data and store in its session variable.
If the AJAX request ends correctly, the content inside the div with ID led is refreshed with the last data values. In the previous image you can see that the LED turns green.
Maybe your application requires Php Controller to work continuously, 24 hours a day 7 days a week.
In this case (but this depends on how much resources your application needs) you must consider to set a managed autorestart, in order to free the memory and continue to get good performance from your system, because it's possible that custom scripts can allocate more and more memory day by day. We're speaking about a managed autorestart because we must be sure that Php Controller automatically stops its elaboration and closes the working session correctly before platform restarting and, during reboot, it must be started automatically in order to continue its elaboration.
In other cases you may simply desire to automatically start Php Controller at system startup, or define an automatic shutdown of your platform at a predetermined time.
In all the cases you need to configure your platform as follows.
Edit the file crontab
At the end of the file add these lines
Where 0 2 * * * means "execute the following command at 02:00 AM o'clock, every day, every month, every year" and 1 2 * * * means "execute the following command at 02:01 AM o'clock, every day, every month, every year". In this way you can correctly stop the controller and make an automatic system shutdown.
Pay attention to write the right path of your project.
Now edit the file rc.local
and add these line in order to automatically start Php Controller at system startup
Also in this case pay attention to write the right path of your project.
That's all!