This topic is locked
[SOLVED]

temporarily close a database

10/10/2024 3:34:42 AM
PHPRunner General questions
R
Rudy Lambrechts author

Hi, I am looking for a way to temporarily close a database for maintenance. Can anyone help me?

Sergey Kornilov admin 10/10/2024

You can use AfterAppInit event for this purpose.

if ( some condition) {
echo "Database is closed for maintenance";
exit();
}
R
Rudy Lambrechts author 10/10/2024

Thanks Sergey,
Can you tell me what's wrong ? I can't find it

$maintenance_mode = true;
{
global $maintenance_mode;

if ($maintenance_mode) {
echo'# Site Maintenance';
echo'We are currently performing maintenance..
';
exit();
}
}

C
cristi 10/10/2024

just curious: what is $maintenance_mode? - is there a parameter like this defined in phprunner documentation?
There are many ways simple or elaborate to do this:

  • simple: just add return false; in before login event of the login page and in designer mode for the login page insert an html text with your message. When you finish the maintenance delete the code from event and the html message and rebuild/upload.
  • simple: use an redirect to a html page with maintenance mode created by you in after login.
  • elaborate: create a dropdown with value on or off for the maintenance mode in a page accesible only to admins, query that value before login, use the buit in $message to display message to users and use it in a conditional with return false for the before login event.
  • more elaborate: create a table with options that only admins can acces define in that table a variable "maintenance_mode" that only admins can change, query that table before login and use that value to allow acces only to admins using security api or nobody - it is up to you, also use the built in $message to display a message to users.

Sergey Kornilov admin 10/10/2024

img alt

R
Rudy Lambrechts author 10/11/2024

Thanks, problem solved !