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