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