]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Console/Maintenance.php
Revert "Moved .htconfig.php file & extracted Install business logic"
[friendica.git] / src / Core / Console / Maintenance.php
index 19067940d178175d6f5c05e35a4ed1b12674487b..6638e4bfe168c477a2f5349d3506af7825091b6c 100644 (file)
-<?php\r
-\r
-namespace Friendica\Core\Console;\r
-\r
-use Friendica\Core;\r
-\r
-require_once 'boot.php';\r
-require_once 'include/dba.php';\r
-\r
-/**\r
- * @brief Sets maintenance mode for this node\r
- *\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class Maintenance extends \Asika\SimpleConsole\Console\r
-{\r
-       protected $helpOptions = ['h', 'help', '?'];\r
-\r
-       protected function getHelp()\r
-       {\r
-               $help = <<<HELP\r
-console maintenance - Sets maintenance mode for this node\r
-Usage\r
-       bin/console maintenance <enable> [<reason>] [-h|--help|-?] [-v]\r
-\r
-Description\r
-       <enable> cen be either 0 or 1 to disabled or enable the maintenance mode on this node.\r
-\r
-       <reason> is a quote-enclosed string with the optional reason for the maintenance mode.\r
-\r
-Examples\r
-       bin/console maintenance 1\r
-               Enables the maintenance mode without setting a reason message\r
-\r
-       bin/console maintenance 1 "SSL certification update"\r
-               Enables the maintenance mode with setting a reason message\r
-\r
-       bin/console maintenance 0\r
-               Disables the maintenance mode\r
-\r
-Options\r
-    -h|--help|-? Show help information\r
-    -v           Show more debug information.\r
-HELP;\r
-               return $help;\r
-       }\r
-\r
-       protected function doExecute()\r
-       {\r
-               if ($this->getOption('v')) {\r
-                       $this->out('Class: ' . __CLASS__);\r
-                       $this->out('Arguments: ' . var_export($this->args, true));\r
-                       $this->out('Options: ' . var_export($this->options, true));\r
-               }\r
-\r
-               if (count($this->args) == 0) {\r
-                       $this->out($this->getHelp());\r
-                       return 0;\r
-               }\r
-\r
-               if (count($this->args) > 2) {\r
-                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
-               }\r
-\r
-               require_once '.htconfig.php';\r
-               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);\r
-               unset($db_host, $db_user, $db_pass, $db_data);\r
-\r
-               if (!$result) {\r
-                       throw new \RuntimeException('Unable to connect to database');\r
-               }\r
-\r
-               Core\Config::load();\r
-\r
-               $lang = Core\L10n::getBrowserLanguage();\r
-               Core\L10n::loadTranslationTable($lang);\r
-\r
-               $enabled = intval($this->getArgument(0));\r
-\r
-               Core\Config::set('system', 'maintenance', $enabled);\r
-\r
-               $reason = $this->getArgument(1);\r
-\r
-               if ($enabled && $this->getArgument(1)) {\r
-                       Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));\r
-               } else {\r
-                       Core\Config::set('system', 'maintenance_reason', '');\r
-               }\r
-\r
-               if ($enabled) {\r
-                       $mode_str = "maintenance mode";\r
-               } else {\r
-                       $mode_str = "normal mode";\r
-               }\r
-\r
-               $this->out('System set in ' . $mode_str);\r
-\r
-               if ($enabled && $reason != '') {\r
-                       $this->out('Maintenance reason: ' . $reason);\r
-               }\r
-\r
-               return 0;\r
-       }\r
-\r
-}\r
+<?php
+
+namespace Friendica\Core\Console;
+
+use Friendica\Core;
+
+require_once 'boot.php';
+require_once 'include/dba.php';
+
+/**
+ * @brief Sets maintenance mode for this node
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+class Maintenance extends \Asika\SimpleConsole\Console
+{
+       protected $helpOptions = ['h', 'help', '?'];
+
+       protected function getHelp()
+       {
+               $help = <<<HELP
+console maintenance - Sets maintenance mode for this node
+Usage
+       bin/console maintenance <enable> [<reason>] [-h|--help|-?] [-v]
+
+Description
+       <enable> cen be either 0 or 1 to disabled or enable the maintenance mode on this node.
+
+       <reason> is a quote-enclosed string with the optional reason for the maintenance mode.
+
+Examples
+       bin/console maintenance 1
+               Enables the maintenance mode without setting a reason message
+
+       bin/console maintenance 1 "SSL certification update"
+               Enables the maintenance mode with setting a reason message
+
+       bin/console maintenance 0
+               Disables the maintenance mode
+
+Options
+    -h|--help|-? Show help information
+    -v           Show more debug information.
+HELP;
+               return $help;
+       }
+
+       protected function doExecute()
+       {
+               $a = get_app();
+
+               if ($this->getOption('v')) {
+                       $this->out('Class: ' . __CLASS__);
+                       $this->out('Arguments: ' . var_export($this->args, true));
+                       $this->out('Options: ' . var_export($this->options, true));
+               }
+
+               if (count($this->args) == 0) {
+                       $this->out($this->getHelp());
+                       return 0;
+               }
+
+               if (count($this->args) > 2) {
+                       throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
+               }
+
+               require_once '.htconfig.php';
+               $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
+               unset($db_host, $db_user, $db_pass, $db_data);
+
+               if (!$result) {
+                       throw new \RuntimeException('Unable to connect to database');
+               }
+
+               Core\Config::load();
+
+               $lang = Core\L10n::getBrowserLanguage();
+               Core\L10n::loadTranslationTable($lang);
+
+               $enabled = intval($this->getArgument(0));
+
+               Core\Config::set('system', 'maintenance', $enabled);
+
+               $reason = $this->getArgument(1);
+
+               if ($enabled && $this->getArgument(1)) {
+                       Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));
+               } else {
+                       Core\Config::set('system', 'maintenance_reason', '');
+               }
+
+               if ($enabled) {
+                       $mode_str = "maintenance mode";
+               } else {
+                       $mode_str = "normal mode";
+               }
+
+               $this->out('System set in ' . $mode_str);
+
+               if ($enabled && $reason != '') {
+                       $this->out('Maintenance reason: ' . $reason);
+               }
+
+               return 0;
+       }
+
+}