3 * @file util/maintenance.php
7 use Friendica\BaseObject;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
11 require_once 'boot.php';
12 require_once 'include/dba.php';
14 $a = new App(dirname(__DIR__));
15 BaseObject::setApp($a);
17 @include(".htconfig.php");
19 $lang = L10n::getBrowserLanguage();
20 L10n::loadTranslationTable($lang);
22 dba::connect($db_host, $db_user, $db_pass, $db_data, false);
23 unset($db_host, $db_user, $db_pass, $db_data);
29 $maint_mode = intval($argv[1]);
32 Config::set('system', 'maintenance', $maint_mode);
34 if ($maint_mode && ($argc > 2)) {
36 array_shift($reason_arr);
37 array_shift($reason_arr);
39 $reason = implode(' ', $reason_arr);
40 Config::set('system', 'maintenance_reason', $reason);
42 Config::set('system', 'maintenance_reason', '');
46 $mode_str = "maintenance mode";
48 $mode_str = "normal mode";
51 echo "\n\tSystem set in $mode_str\n";
54 echo "\tMaintenance reason: $reason\n\n";
60 echo "\tphp {$argv[0]} [1] [Maintenance reason|redirection url]\n";
61 echo "\t\tSet the system in maintenance mode\n\n";
62 echo "\t\tIf the optionally entered maintenance reason is an url\n";
63 echo "\t\tthe visitor is redirected to that page.\n";
65 echo "\t\tExamples:\n";
66 echo "\t\t\tphp {$argv[0]} 1 System upgrade\n";
67 echo "\t\t\tphp {$argv[0]} 1 http://domain.tld/downtime\n";
69 echo "\tphp {$argv[0]} 0\n";
70 echo "\t\tSet the system in normal mode\n\n";