]> git.mxchange.org Git - friendica.git/blob - util/maintenance.php
Merge pull request #4613 from MrPetovan/task/4518-add-cache-delete
[friendica.git] / util / maintenance.php
1 <?php
2 /**
3  * @file util/maintenance.php
4  */
5
6 use Friendica\App;
7 use Friendica\BaseObject;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10
11 require_once 'boot.php';
12 require_once 'include/dba.php';
13
14 $a = new App(dirname(__DIR__));
15 BaseObject::setApp($a);
16
17 @include(".htconfig.php");
18
19 $lang = L10n::getBrowserLanguage();
20 L10n::loadTranslationTable($lang);
21
22 dba::connect($db_host, $db_user, $db_pass, $db_data, false);
23 unset($db_host, $db_user, $db_pass, $db_data);
24
25 Config::load();
26
27 $maint_mode = 1;
28 if ($argc > 1) {
29         $maint_mode = intval($argv[1]);
30 }
31
32 Config::set('system', 'maintenance', $maint_mode);
33
34 if ($maint_mode && ($argc > 2)) {
35         $reason_arr = $argv;
36         array_shift($reason_arr);
37         array_shift($reason_arr);
38
39         $reason = implode(' ', $reason_arr);
40         Config::set('system', 'maintenance_reason', $reason);
41 } else {
42         Config::set('system', 'maintenance_reason', '');
43 }
44
45 if ($maint_mode) {
46         $mode_str = "maintenance mode";
47 } else {
48         $mode_str = "normal mode";
49 }
50
51 echo "\n\tSystem set in $mode_str\n";
52
53 if ($reason != '') {
54         echo "\tMaintenance reason: $reason\n\n";
55 } else {
56         echo "\n";
57 }
58
59 echo "Usage:\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";
64 echo "\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";
68 echo "\n";
69 echo "\tphp {$argv[0]} 0\n";
70 echo "\t\tSet the system in normal mode\n\n";