<?php
+use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
private static $in_transaction = false;
private static $relation = [];
- public static function connect($serveraddr, $user, $pass, $db, $install = false) {
+ public static function connect($serveraddr, $user, $pass, $db) {
if (!is_null(self::$db)) {
return true;
}
return false;
}
- if ($install) {
+ if ($a->mode == App::MODE_INSTALL) {
// server has to be a non-empty string that is not 'localhost' and not an IP
if (strlen($server) && ($server !== 'localhost') && filter_var($server, FILTER_VALIDATE_IP) === false) {
if (! dns_get_record($server, DNS_A + DNS_CNAME)) {
// turn off logger in install mode
if (
- $a->mode == APP_MODE_INSTALL
+ $a->mode == App::MODE_INSTALL
|| !dba::$connected
) {
return;
// turn off logger in install mode
if (
- $a->mode == APP_MODE_INSTALL
+ $a->mode == App::MODE_INSTALL
|| !dba::$connected
) {
return;
$a->backend = false;
// Only load config if found, don't suppress errors
-if (!$a->mode == APP_MODE_INSTALL) {
+if (!$a->mode == App::MODE_INSTALL) {
include ".htconfig.php";
}
require_once "include/dba.php";
-if (!$a->mode == APP_MODE_INSTALL) {
+if (!$a->mode == App::MODE_INSTALL) {
$result = dba::connect($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
Addon::loadHooks();
Addon::callHooks('init_1');
- $a->mode = ((Config::get('system', 'maintenance')) ? APP_MODE_MAINTENANCE : APP_MODE_NORMAL);
+ $a->checkMaintenanceMode();
}
$lang = L10n::getBrowserLanguage();
L10n::loadTranslationTable($lang);
}
-if ((x($_GET, 'zrl')) && $a->mode == APP_MODE_NORMAL) {
+if ((x($_GET, 'zrl')) && $a->mode == App::MODE_NORMAL) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "")
// in install mode, any url loads install module
// but we need "view" module for stylesheet
-if ($a->mode == APP_MODE_INSTALL && $a->module!="view") {
+if ($a->mode == App::MODE_INSTALL && $a->module!="view") {
$a->module = 'install';
-} elseif ($a->mode == APP_MODE_MAINTENANCE && $a->module!="view") {
+} elseif ($a->mode == App::MODE_MAINTENANCE && $a->module!="view") {
$a->module = 'maintenance';
} else {
check_url($a);
$a->page['content'] = '';
}
-if ($a->mode == APP_MODE_NORMAL) {
+if ($a->mode == App::MODE_NORMAL) {
Addon::callHooks('page_content_top', $a->page['content']);
}
$phpath = notags(trim($_POST['phpath']));
require_once("include/dba.php");
- if (!dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true)) {
+ if (!dba::connect($dbhost, $dbuser, $dbpass, $dbdata)) {
$a->data['db_conn_failed'] = true;
}
$rino = 1;
// connect to db
- dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true);
+ dba::connect($dbhost, $dbuser, $dbpass, $dbdata);
Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino);
use Exception;
-define ('APP_MODE_NORMAL', 0);
-define ('APP_MODE_INSTALL', 1);
-define ('APP_MODE_MAINTENANCE', 2);
-
require_once 'boot.php';
require_once 'include/text.php';
*/
class App
{
+ const MODE_NORMAL = 0;
+ const MODE_INSTALL = 1;
+ const MODE_MAINTENANCE = 2;
+
public $module_loaded = false;
public $module_class = null;
public $query_string;
public $argv;
public $argc;
public $module;
- public $mode = APP_MODE_NORMAL;
+ public $mode = App::MODE_NORMAL;
public $pager;
public $strings;
public $basepath;
* Ignore errors. If the file doesn't exist or is empty, we are running in
* installation mode. *
*/
- $this->mode = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? APP_MODE_NORMAL : APP_MODE_INSTALL);
+ $this->mode = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? App::MODE_NORMAL : App::MODE_INSTALL);
self::$a = $this;
return $sender_email;
}
+
+ /**
+ * @note Checks, if the App is in the Maintenance-Mode
+ *
+ * @return boolean
+ */
+ public function checkMaintenanceMode()
+ {
+ if (Config::get('system', 'maintenance')) {
+ $this->mode = App::MODE_MAINTENANCE;
+ return true;
+ }
+
+ return false;
+ }
}
);
- if (!dba::connect($db_host, $db_user, $db_pass, $db_data, true)) {
+ if (!dba::connect($db_host, $db_user, $db_pass, $db_data)) {
$result['status'] = false;
$result['help'] = 'Failed, please check your MySQL settings and credentials.';
}
namespace Friendica\Core;\r
\r
use Friendica\BaseObject;\r
+use Friendica\App;\r
use Friendica\Database\DBStructure;\r
use Friendica\Object\Image;\r
use Friendica\Util\Network;\r
class Install extends BaseObject\r
{\r
public static function setInstallMode() {\r
- self::getApp()->mode = APP_MODE_INSTALL;\r
+ self::getApp()->mode = App::MODE_INSTALL;\r
}\r
\r
public static function check($phpath = 'php')\r