admin.php 9.38 KB
Newer Older
1
2
<?php
/**
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 * @author Arthur Schiwon <blizzz@owncloud.com>
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Frank Karlitschek <frank@owncloud.org>
 * @author Georg Ehrke <georg@owncloud.com>
 * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
 * @author Joas Schilling <nickvergessen@owncloud.com>
 * @author Lukas Reschke <lukas@owncloud.com>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin Appelman <icewind@owncloud.com>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 * @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/>
 *
30
 */
31

32
OC_Util::checkAdminUser();
33
OC_App::setActiveNavigationEntry("admin");
34

35
36
$template = new OC_Template('settings', 'admin', 'user');

37
38
39
40
41
42
43
44
$showLog = (\OC::$server->getConfig()->getSystemValue('log_type', 'owncloud') === 'owncloud');
$numEntriesToLoad = 3;
$entries = OC_Log_Owncloud::getEntries($numEntriesToLoad + 1);
$entriesRemaining = count($entries) > $numEntriesToLoad;
$entries = array_slice($entries, 0, $numEntriesToLoad);
$logFilePath = OC_Log_Owncloud::getLogFilePath();
$doesLogFileExist = file_exists($logFilePath);
$logFileSize = filesize($logFilePath);
45
$config = \OC::$server->getConfig();
46
$appConfig = \OC::$server->getAppConfig();
47
$request = \OC::$server->getRequest();
48

49
// Should we display sendmail as an option?
50
$template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
51
52
53
54
55
56
57
58
59
60
61
62
63
64

$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
$template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
$template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
$template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
$template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
$template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
$template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
$template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
$template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
$template->assign('entries', $entries);
$template->assign('entriesremain', $entriesRemaining);
65
66
67
$template->assign('logFileSize', $logFileSize);
$template->assign('doesLogFileExist', $doesLogFileExist);
$template->assign('showLog', $showLog);
Lukas Reschke's avatar
Lukas Reschke committed
68
$template->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled());
69
70
71
72
73
74
75
76
77
78
79
80
81
$template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
$template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
$template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
$template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax'));
$template->assign('cron_log', $config->getSystemValue('cron_log', true));
$template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false));
$template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes'));
$template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no'));
$template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7'));
$template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no'));
$excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
$template->assign('shareExcludeGroups', $excludeGroups);
$excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
82
$excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
83
$template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
$template->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
$encryptionModules = \OC::$server->getEncryptionManager()->getEncryptionModules();
try {
	$defaultEncryptionModule = \OC::$server->getEncryptionManager()->getDefaultEncryptionModule();
	$defaultEncryptionModuleId = $defaultEncryptionModule->getId();
} catch (Exception $e) {
	$defaultEncryptionModule = null;
}
$encModulues = array();
foreach ($encryptionModules as $module) {
	$encModulues[$module->getId()]['displayName'] = $module->getDisplayName();
	$encModulues[$module->getId()]['default'] = false;
	if ($defaultEncryptionModule && $module->getId() === $defaultEncryptionModuleId) {
		$encModulues[$module->getId()]['default'] = true;
	}
}
$template->assign('encryptionModules', $encModulues);
101

102
// If the current web root is non-empty but the web root from the config is,
103
// and system cron is used, the URL generator fails to build valid URLs.
104
$shouldSuggestOverwriteCliUrl = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
105
	\OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
106
107
108
	!$config->getSystemValue('overwrite.cli.url', '');
$suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : '';
$template->assign('suggestedOverwriteCliUrl', $suggestedOverwriteCliUrl);
Morris Jobke's avatar
Morris Jobke committed
109

110
111
112
113
$template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes'));
$template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
$template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
$template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
114
$template->assign('allowPublicMailNotification', $appConfig->getValue('core', 'shareapi_allow_public_notification', 'no'));
115
116
$template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
$template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
Morris Jobke's avatar
Morris Jobke committed
117
$databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
118
$template->assign('databaseOverload', $databaseOverload);
119
$template->assign('cronErrors', $appConfig->getValue('core', 'cronErrors'));
120

Frank Karlitschek's avatar
Frank Karlitschek committed
121
122
// warn if Windows is used
$template->assign('WindowsWarning', OC_Util::runningOnWindows());
123

124
125
126
127
// warn if outdated version of APCu is used
$template->assign('ApcuOutdatedWarning',
	extension_loaded('apcu') && version_compare(phpversion('apc'), '4.0.6') === -1);

128
129
130
131
// add hardcoded forms from the template
$forms = OC_App::getForms('admin');
$l = OC_L10N::get('settings');
$formsAndMore = array();
132
if ($request->getServerProtocol()  !== 'https' || !OC_Util::isAnnotationsWorking() ||
Lukas Reschke's avatar
Lukas Reschke committed
133
	$suggestedOverwriteCliUrl || !OC_Util::isSetLocaleWorking()  ||
134
	!OC_Util::fileInfoLoaded() || $databaseOverload
135
) {
136
	$formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & setup warnings'));
137
}
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
$formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));

// Prioritize fileSharingSettings and files_external and move updater to the version
$fileSharingSettings = $filesExternal = $updaterAppPanel = '';
foreach ($forms as $index => $form) {
	if (strpos($form, 'id="fileSharingSettings"')) {
		$fileSharingSettings = $form;
		unset($forms[$index]);
		continue;
	}
	if (strpos($form, 'id="files_external"')) {
		$filesExternal = $form;
		unset($forms[$index]);
		continue;
	}
	if (strpos($form, 'class="updater-admin"')) {
		$updaterAppPanel = $form;
		unset($forms[$index]);
		continue;
	}
}
if ($filesExternal) {
	$formsAndMore[] = array('anchor' => 'files_external', 'section-name' => $l->t('External Storage'));
}
$template->assign('fileSharingSettings', $fileSharingSettings);
$template->assign('filesExternal', $filesExternal);
$template->assign('updaterAppPanel', $updaterAppPanel);
165
166
167
168
169
170
171
172
173

$formsMap = array_map(function ($form) {
	if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) {
		$sectionName = str_replace('<h2>', '', $regs[0]);
		$sectionName = str_replace('</h2>', '', $sectionName);
		$anchor = strtolower($sectionName);
		$anchor = str_replace(' ', '-', $anchor);

		return array(
174
			'anchor' => 'goto-' . $anchor,
175
176
177
178
179
180
181
182
183
184
185
186
187
188
			'section-name' => $sectionName,
			'form' => $form
		);
	}
	return array(
		'form' => $form
	);
}, $forms);

$formsAndMore = array_merge($formsAndMore, $formsMap);

// add bottom hardcoded forms from the template
$formsAndMore[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron'));
$formsAndMore[] = array('anchor' => 'mail_general_settings', 'section-name' => $l->t('Email Server'));
189
$formsAndMore[] = array('anchor' => 'log-section', 'section-name' => $l->t('Log'));
190
$formsAndMore[] = array('anchor' => 'admin-tips', 'section-name' => $l->t('Tips & tricks'));
Joas Schilling's avatar
Joas Schilling committed
191
192
193
if ($updaterAppPanel) {
	$formsAndMore[] = array('anchor' => 'updater', 'section-name' => $l->t('Updates'));
}
194
195

$template->assign('forms', $formsAndMore);
Morris Jobke's avatar
Morris Jobke committed
196

197
$template->printPage();