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