3 namespace Friendica\Core\Console;
\r
7 require_once 'boot.php';
\r
8 require_once 'include/dba.php';
\r
11 * @brief tool to silence accounts on the global community page
\r
13 * With this tool, you can silence an account on the global community page.
\r
14 * Postings from silenced accounts will not be displayed on the community
\r
15 * page. This silencing does only affect the display on the community page,
\r
16 * accounts following the silenced accounts will still get their postings.
\r
18 * Usage: pass the URL of the profile to be silenced account as only parameter
\r
19 * at the command line when running this tool. E.g.
\r
21 * $> util/global_community_silence.php http://example.com/profile/bob
\r
23 * will silence bob@example.com so that his postings won't appear at
\r
24 * the global community page.
\r
26 * License: AGPLv3 or later, same as Friendica
\r
28 * @author Tobias Diekershoff
\r
29 * @author Hypolite Petovan <mrpetovan@gmail.com>
\r
31 class Maintenance extends \Asika\SimpleConsole\Console
\r
33 protected $helpOptions = ['h', 'help', '?'];
\r
35 protected function getHelp()
\r
38 console maintenance - Sets maintenance mode for this node
\r
40 bin/console maintenance <enable> [<reason>] [-h|--help|-?] [-v]
\r
43 <enable> cen be either 0 or 1 to disabled or enable the maintenance mode on this node.
\r
45 <reason> is a quote-enclosed string with the optional reason for the maintenance mode.
\r
48 bin/console maintenance 1
\r
49 Enables the maintenance mode without setting a reason message
\r
51 bin/console maintenance 1 "SSL certification update"
\r
52 Enables the maintenance mode with setting a reason message
\r
54 bin/console maintenance 0
\r
55 Disables the maintenance mode
\r
58 -h|--help|-? Show help information
\r
59 -v Show more debug information.
\r
64 protected function doExecute()
\r
66 if ($this->getOption('v')) {
\r
67 $this->out('Class: ' . __CLASS__);
\r
68 $this->out('Arguments: ' . var_export($this->args, true));
\r
69 $this->out('Options: ' . var_export($this->options, true));
\r
72 if (count($this->args) == 0) {
\r
73 $this->out($this->getHelp());
\r
77 if (count($this->args) > 2) {
\r
78 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
\r
81 require_once '.htconfig.php';
\r
82 $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
\r
83 unset($db_host, $db_user, $db_pass, $db_data);
\r
86 throw new \RuntimeException('Unable to connect to database');
\r
89 Core\Config::load();
\r
91 $lang = Core\L10n::getBrowserLanguage();
\r
92 Core\L10n::loadTranslationTable($lang);
\r
94 $enabled = intval($this->getArgument(0));
\r
96 Core\Config::set('system', 'maintenance', $enabled);
\r
98 $reason = $this->getArgument(1);
\r
100 if ($enabled && $this->getArgument(1)) {
\r
101 Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));
\r
103 Core\Config::set('system', 'maintenance_reason', '');
\r
107 $mode_str = "maintenance mode";
\r
109 $mode_str = "normal mode";
\r
112 $this->out('System set in ' . $mode_str);
\r
114 if ($enabled && $reason != '') {
\r
115 $this->out('Maintenance reason: ' . $reason);
\r