]> git.mxchange.org Git - friendica.git/blob - util/maintenance.php
"dba" is now a static class
[friendica.git] / util / maintenance.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\Config;
5
6 require_once("boot.php");
7
8 $a = new App(dirname(__DIR__));
9 @include(".htconfig.php");
10
11 $lang = get_browser_language();
12 load_translation_table($lang);
13
14 require_once("include/dba.php");
15 dba::connect($db_host, $db_user, $db_pass, $db_data, false);
16 unset($db_host, $db_user, $db_pass, $db_data);
17
18 Config::load();
19
20 $maint_mode = 1;
21 if ($argc > 1) {
22         $maint_mode = intval($argv[1]);
23 }
24
25 Config::set('system', 'maintenance', $maint_mode);
26
27 if ($maint_mode && ($argc > 2)) {
28         $reason_arr = $argv;
29         array_shift($reason_arr);
30         array_shift($reason_arr);
31
32         $reason = implode(' ', $reason_arr);
33         Config::set('system', 'maintenance_reason', $reason);
34 } else {
35         Config::set('system', 'maintenance_reason', '');
36 }
37
38 if ($maint_mode) {
39         $mode_str = "maintenance mode";
40 } else {
41         $mode_str = "normal mode";
42 }
43
44 echo "\n\tSystem set in $mode_str\n";
45
46 if ($reason != '') {
47         echo "\tMaintenance reason: $reason\n\n";
48 } else {
49         echo "\n";
50 }
51
52 echo "Usage:\n\n";
53 echo "\tphp {$argv[0]} [1] [Maintenance reason|redirection url]\n";
54 echo "\t\tSet the system in maintenance mode\n\n";
55 echo "\t\tIf the optionally entered maintenance reason is an url\n";
56 echo "\t\tthe visitor is redirected to that page.\n";
57 echo "\n";
58 echo "\t\tExamples:\n";
59 echo "\t\t\tphp {$argv[0]} 1 System upgrade\n";
60 echo "\t\t\tphp {$argv[0]} 1 http://domain.tld/downtime\n";
61 echo "\n";
62 echo "\tphp {$argv[0]} 0\n";
63 echo "\t\tSet the system in normal mode\n\n";