summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
Diffstat (limited to 'settings')
-rw-r--r--settings/ajax/checksetup.php40
-rw-r--r--settings/application.php18
-rw-r--r--settings/controller/checksetupcontroller.php99
-rw-r--r--settings/routes.php3
4 files changed, 117 insertions, 43 deletions
diff --git a/settings/ajax/checksetup.php b/settings/ajax/checksetup.php
deleted file mode 100644
index 6e41c11e050..00000000000
--- a/settings/ajax/checksetup.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Vincent Petry <pvince81@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-OCP\JSON::checkAdminUser();
-OCP\JSON::callCheck();
-
-\OC::$server->getSession()->close();
-
-// no warning when has_internet_connection is false in the config
-$hasInternet = true;
-if (OC_Util::isInternetConnectionEnabled()) {
- $hasInternet = OC_Util::isInternetConnectionWorking(\OC::$server->getHTTPClientService());
-}
-
-OCP\JSON::success(
- array (
- 'serverHasInternetConnection' => $hasInternet,
- 'dataDirectoryProtected' => OC_Util::isHtaccessWorking()
- )
-);
diff --git a/settings/application.php b/settings/application.php
index 397e3b3de91..b4596037964 100644
--- a/settings/application.php
+++ b/settings/application.php
@@ -24,6 +24,7 @@
namespace OC\Settings;
use OC\Settings\Controller\AppSettingsController;
+use OC\Settings\Controller\CheckSetupController;
use OC\Settings\Controller\GroupsController;
use OC\Settings\Controller\LogSettingsController;
use OC\Settings\Controller\MailSettingsController;
@@ -44,7 +45,7 @@ class Application extends App {
/**
* @param array $urlParams
*/
- public function __construct(array $urlParams=array()){
+ public function __construct(array $urlParams=[]){
parent::__construct('settings', $urlParams);
$container = $this->getContainer();
@@ -117,6 +118,15 @@ class Application extends App {
$c->query('L10N')
);
});
+ $container->registerService('CheckSetupController', function(IContainer $c) {
+ return new CheckSetupController(
+ $c->query('AppName'),
+ $c->query('Request'),
+ $c->query('Config'),
+ $c->query('ClientService'),
+ $c->query('Util')
+ );
+ });
/**
* Middleware
@@ -178,5 +188,11 @@ class Application extends App {
$container->registerService('URLGenerator', function(IContainer $c) {
return $c->query('ServerContainer')->getURLGenerator();
});
+ $container->registerService('ClientService', function(IContainer $c) {
+ return $c->query('ServerContainer')->getHTTPClientService();
+ });
+ $container->registerService('Util', function(IContainer $c) {
+ return new \OC_Util();
+ });
}
}
diff --git a/settings/controller/checksetupcontroller.php b/settings/controller/checksetupcontroller.php
new file mode 100644
index 00000000000..ae3f1b99c52
--- /dev/null
+++ b/settings/controller/checksetupcontroller.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * @author Lukas Reschke <lukas@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Settings\Controller;
+
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\Http\Client\IClientService;
+use OCP\IConfig;
+use OCP\IRequest;
+use OC_Util;
+
+/**
+ * @package OC\Settings\Controller
+ */
+class CheckSetupController extends Controller {
+ /** @var IConfig */
+ private $config;
+ /** @var IClientService */
+ private $clientService;
+ /** @var \OC_Util */
+ private $util;
+
+ /**
+ * @param string $AppName
+ * @param IRequest $request
+ * @param IConfig $config
+ * @param IClientService $clientService
+ * @param \OC_Util $util
+ */
+ public function __construct($AppName,
+ IRequest $request,
+ IConfig $config,
+ IClientService $clientService,
+ \OC_Util $util) {
+ parent::__construct($AppName, $request);
+ $this->config = $config;
+ $this->clientService = $clientService;
+ $this->util = $util;
+ }
+
+ /**
+ * Checks if the ownCloud server can connect to the internet using HTTPS and HTTP
+ * @return bool
+ */
+ private function isInternetConnectionWorking() {
+ if ($this->config->getSystemValue('has_internet_connection', true) === false) {
+ return false;
+ }
+
+ try {
+ $client = $this->clientService->newClient();
+ $client->get('https://www.owncloud.org/');
+ $client->get('http://www.owncloud.org/');
+ return true;
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks whether a local memcache is installed or not
+ * @return bool
+ */
+ private function isMemcacheConfigured() {
+ return $this->config->getSystemValue('memcache.local', null) !== null;
+ }
+
+ /**
+ * @return DataResponse
+ */
+ public function check() {
+ return new DataResponse(
+ [
+ 'serverHasInternetConnection' => $this->isInternetConnectionWorking(),
+ 'dataDirectoryProtected' => $this->util->isHtaccessWorking($this->config),
+ 'isMemcacheConfigured' => $this->isMemcacheConfigured(),
+ ]
+ );
+ }
+}
diff --git a/settings/routes.php b/settings/routes.php
index 5a567bb99ff..5a069e5a1c6 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -49,6 +49,7 @@ $application->registerRoutes($this, array(
array('name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'),
array('name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'),
array('name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'),
+ ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'],
)
));
@@ -112,5 +113,3 @@ $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect
// admin
$this->create('settings_ajax_excludegroups', '/settings/ajax/excludegroups.php')
->actionInclude('settings/ajax/excludegroups.php');
-$this->create('settings_ajax_checksetup', '/settings/ajax/checksetup')
- ->actionInclude('settings/ajax/checksetup.php');