@@ -25,26 +25,26 @@ discard block |
||
25 | 25 | /** @var array $_ */ |
26 | 26 | |
27 | 27 | $mail_smtpauthtype = [ |
28 | - '' => $l->t('None'), |
|
29 | - 'LOGIN' => $l->t('Login'), |
|
30 | - 'PLAIN' => $l->t('Plain'), |
|
31 | - 'NTLM' => $l->t('NT LAN Manager'), |
|
28 | + '' => $l->t('None'), |
|
29 | + 'LOGIN' => $l->t('Login'), |
|
30 | + 'PLAIN' => $l->t('Plain'), |
|
31 | + 'NTLM' => $l->t('NT LAN Manager'), |
|
32 | 32 | ]; |
33 | 33 | |
34 | 34 | $mail_smtpsecure = [ |
35 | - '' => $l->t('None'), |
|
36 | - 'ssl' => $l->t('SSL/TLS'), |
|
37 | - 'tls' => $l->t('STARTTLS'), |
|
35 | + '' => $l->t('None'), |
|
36 | + 'ssl' => $l->t('SSL/TLS'), |
|
37 | + 'tls' => $l->t('STARTTLS'), |
|
38 | 38 | ]; |
39 | 39 | |
40 | 40 | $mail_smtpmode = [ |
41 | - ['smtp', 'SMTP'], |
|
41 | + ['smtp', 'SMTP'], |
|
42 | 42 | ]; |
43 | 43 | if ($_['sendmail_is_available']) { |
44 | - $mail_smtpmode[] = ['sendmail', 'Sendmail']; |
|
44 | + $mail_smtpmode[] = ['sendmail', 'Sendmail']; |
|
45 | 45 | } |
46 | 46 | if ($_['mail_smtpmode'] === 'qmail') { |
47 | - $mail_smtpmode[] = ['qmail', 'qmail']; |
|
47 | + $mail_smtpmode[] = ['qmail', 'qmail']; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | ?> |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | <label for="mail_smtpmode"><?php p($l->t('Send mode')); ?></label> |
63 | 63 | <select name="mail_smtpmode" id="mail_smtpmode"> |
64 | 64 | <?php foreach ($mail_smtpmode as $smtpmode): |
65 | - $selected = ''; |
|
66 | - if ($smtpmode[0] == $_['mail_smtpmode']): |
|
67 | - $selected = 'selected="selected"'; |
|
68 | - endif; ?> |
|
65 | + $selected = ''; |
|
66 | + if ($smtpmode[0] == $_['mail_smtpmode']): |
|
67 | + $selected = 'selected="selected"'; |
|
68 | + endif; ?> |
|
69 | 69 | <option value="<?php p($smtpmode[0])?>" <?php p($selected) ?>><?php p($smtpmode[1]) ?></option> |
70 | 70 | <?php endforeach;?> |
71 | 71 | </select> |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | <select name="mail_smtpsecure" id="mail_smtpsecure" |
78 | 78 | <?php if ($_['mail_smtpmode'] !== 'smtp') print_unescaped(' class="hidden"'); ?>> |
79 | 79 | <?php foreach ($mail_smtpsecure as $secure => $name): |
80 | - $selected = ''; |
|
81 | - if ($secure == $_['mail_smtpsecure']): |
|
82 | - $selected = 'selected="selected"'; |
|
83 | - endif; ?> |
|
80 | + $selected = ''; |
|
81 | + if ($secure == $_['mail_smtpsecure']): |
|
82 | + $selected = 'selected="selected"'; |
|
83 | + endif; ?> |
|
84 | 84 | <option value="<?php p($secure)?>" <?php p($selected) ?>><?php p($name) ?></option> |
85 | 85 | <?php endforeach;?> |
86 | 86 | </select> |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | <label for="mail_smtpauthtype"><?php p($l->t('Authentication method')); ?></label> |
99 | 99 | <select name="mail_smtpauthtype" id="mail_smtpauthtype'> |
100 | 100 | <?php foreach ($mail_smtpauthtype as $authtype => $name): |
101 | - $selected = ''; |
|
102 | - if ($authtype == $_['mail_smtpauthtype']): |
|
103 | - $selected = 'selected="selected"'; |
|
104 | - endif; ?> |
|
101 | + $selected = ''; |
|
102 | + if ($authtype == $_['mail_smtpauthtype']): |
|
103 | + $selected = 'selected="selected"'; |
|
104 | + endif; ?> |
|
105 | 105 | <option value="<?php p($authtype)?>" <?php p($selected) ?>><?php p($name) ?></option> |
106 | 106 | <?php endforeach;?> |
107 | 107 | </select> |
@@ -30,61 +30,61 @@ |
||
30 | 30 | use OCP\Settings\ISettings; |
31 | 31 | |
32 | 32 | class Mail implements ISettings { |
33 | - /** @var IConfig */ |
|
34 | - private $config; |
|
33 | + /** @var IConfig */ |
|
34 | + private $config; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param IConfig $config |
|
38 | - */ |
|
39 | - public function __construct(IConfig $config) { |
|
40 | - $this->config = $config; |
|
41 | - } |
|
36 | + /** |
|
37 | + * @param IConfig $config |
|
38 | + */ |
|
39 | + public function __construct(IConfig $config) { |
|
40 | + $this->config = $config; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return TemplateResponse |
|
45 | - */ |
|
46 | - public function getForm() { |
|
47 | - $parameters = [ |
|
48 | ||
49 | - 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'), |
|
50 | - 'mail_domain' => $this->config->getSystemValue('mail_domain', ''), |
|
51 | - 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''), |
|
52 | - 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''), |
|
53 | - 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''), |
|
54 | - 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''), |
|
55 | - 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''), |
|
56 | - 'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''), |
|
57 | - 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false), |
|
58 | - 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''), |
|
59 | - 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''), |
|
60 | - ]; |
|
43 | + /** |
|
44 | + * @return TemplateResponse |
|
45 | + */ |
|
46 | + public function getForm() { |
|
47 | + $parameters = [ |
|
48 | ||
49 | + 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'), |
|
50 | + 'mail_domain' => $this->config->getSystemValue('mail_domain', ''), |
|
51 | + 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''), |
|
52 | + 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''), |
|
53 | + 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''), |
|
54 | + 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''), |
|
55 | + 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''), |
|
56 | + 'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''), |
|
57 | + 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false), |
|
58 | + 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''), |
|
59 | + 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''), |
|
60 | + ]; |
|
61 | 61 | |
62 | - if ($parameters['mail_smtppassword'] !== '') { |
|
63 | - $parameters['mail_smtppassword'] = '********'; |
|
64 | - } |
|
62 | + if ($parameters['mail_smtppassword'] !== '') { |
|
63 | + $parameters['mail_smtppassword'] = '********'; |
|
64 | + } |
|
65 | 65 | |
66 | - if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') { |
|
67 | - $parameters['mail_smtpmode'] = 'smtp'; |
|
68 | - } |
|
66 | + if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') { |
|
67 | + $parameters['mail_smtpmode'] = 'smtp'; |
|
68 | + } |
|
69 | 69 | |
70 | - return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, ''); |
|
71 | - } |
|
70 | + return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, ''); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return string the section ID, e.g. 'sharing' |
|
75 | - */ |
|
76 | - public function getSection() { |
|
77 | - return 'server'; |
|
78 | - } |
|
73 | + /** |
|
74 | + * @return string the section ID, e.g. 'sharing' |
|
75 | + */ |
|
76 | + public function getSection() { |
|
77 | + return 'server'; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return int whether the form should be rather on the top or bottom of |
|
82 | - * the admin section. The forms are arranged in ascending order of the |
|
83 | - * priority values. It is required to return a value between 0 and 100. |
|
84 | - * |
|
85 | - * E.g.: 70 |
|
86 | - */ |
|
87 | - public function getPriority() { |
|
88 | - return 10; |
|
89 | - } |
|
80 | + /** |
|
81 | + * @return int whether the form should be rather on the top or bottom of |
|
82 | + * the admin section. The forms are arranged in ascending order of the |
|
83 | + * priority values. It is required to return a value between 0 and 100. |
|
84 | + * |
|
85 | + * E.g.: 70 |
|
86 | + */ |
|
87 | + public function getPriority() { |
|
88 | + return 10; |
|
89 | + } |
|
90 | 90 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $mailer = $this->getInstance(); |
173 | 173 | |
174 | 174 | // Enable logger if debug mode is enabled |
175 | - if($debugMode) { |
|
175 | + if ($debugMode) { |
|
176 | 176 | $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger(); |
177 | 177 | $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger)); |
178 | 178 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | // Debugging logging |
183 | 183 | $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject()); |
184 | 184 | $this->logger->debug($logMessage, ['app' => 'core']); |
185 | - if($debugMode && isset($mailLogger)) { |
|
185 | + if ($debugMode && isset($mailLogger)) { |
|
186 | 186 | $this->logger->debug($mailLogger->dump(), ['app' => 'core']); |
187 | 187 | } |
188 | 188 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | list($name, $domain) = explode('@', $email, 2); |
219 | - $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46); |
|
219 | + $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
|
220 | 220 | return $name.'@'.$domain; |
221 | 221 | } |
222 | 222 | |
@@ -281,6 +281,6 @@ discard block |
||
281 | 281 | break; |
282 | 282 | } |
283 | 283 | |
284 | - return new \Swift_SendmailTransport($binaryPath . ' -bs'); |
|
284 | + return new \Swift_SendmailTransport($binaryPath.' -bs'); |
|
285 | 285 | } |
286 | 286 | } |
@@ -57,227 +57,227 @@ |
||
57 | 57 | * @package OC\Mail |
58 | 58 | */ |
59 | 59 | class Mailer implements IMailer { |
60 | - /** @var \Swift_Mailer Cached mailer */ |
|
61 | - private $instance = null; |
|
62 | - /** @var IConfig */ |
|
63 | - private $config; |
|
64 | - /** @var ILogger */ |
|
65 | - private $logger; |
|
66 | - /** @var Defaults */ |
|
67 | - private $defaults; |
|
68 | - /** @var IURLGenerator */ |
|
69 | - private $urlGenerator; |
|
70 | - /** @var IL10N */ |
|
71 | - private $l10n; |
|
60 | + /** @var \Swift_Mailer Cached mailer */ |
|
61 | + private $instance = null; |
|
62 | + /** @var IConfig */ |
|
63 | + private $config; |
|
64 | + /** @var ILogger */ |
|
65 | + private $logger; |
|
66 | + /** @var Defaults */ |
|
67 | + private $defaults; |
|
68 | + /** @var IURLGenerator */ |
|
69 | + private $urlGenerator; |
|
70 | + /** @var IL10N */ |
|
71 | + private $l10n; |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param IConfig $config |
|
75 | - * @param ILogger $logger |
|
76 | - * @param Defaults $defaults |
|
77 | - * @param IURLGenerator $urlGenerator |
|
78 | - * @param IL10N $l10n |
|
79 | - */ |
|
80 | - public function __construct(IConfig $config, |
|
81 | - ILogger $logger, |
|
82 | - Defaults $defaults, |
|
83 | - IURLGenerator $urlGenerator, |
|
84 | - IL10N $l10n) { |
|
85 | - $this->config = $config; |
|
86 | - $this->logger = $logger; |
|
87 | - $this->defaults = $defaults; |
|
88 | - $this->urlGenerator = $urlGenerator; |
|
89 | - $this->l10n = $l10n; |
|
90 | - } |
|
73 | + /** |
|
74 | + * @param IConfig $config |
|
75 | + * @param ILogger $logger |
|
76 | + * @param Defaults $defaults |
|
77 | + * @param IURLGenerator $urlGenerator |
|
78 | + * @param IL10N $l10n |
|
79 | + */ |
|
80 | + public function __construct(IConfig $config, |
|
81 | + ILogger $logger, |
|
82 | + Defaults $defaults, |
|
83 | + IURLGenerator $urlGenerator, |
|
84 | + IL10N $l10n) { |
|
85 | + $this->config = $config; |
|
86 | + $this->logger = $logger; |
|
87 | + $this->defaults = $defaults; |
|
88 | + $this->urlGenerator = $urlGenerator; |
|
89 | + $this->l10n = $l10n; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Creates a new message object that can be passed to send() |
|
94 | - * |
|
95 | - * @return IMessage |
|
96 | - */ |
|
97 | - public function createMessage(): IMessage { |
|
98 | - $plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false); |
|
99 | - return new Message(new \Swift_Message(), $plainTextOnly); |
|
100 | - } |
|
92 | + /** |
|
93 | + * Creates a new message object that can be passed to send() |
|
94 | + * |
|
95 | + * @return IMessage |
|
96 | + */ |
|
97 | + public function createMessage(): IMessage { |
|
98 | + $plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false); |
|
99 | + return new Message(new \Swift_Message(), $plainTextOnly); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @param string|null $data |
|
104 | - * @param string|null $filename |
|
105 | - * @param string|null $contentType |
|
106 | - * @return IAttachment |
|
107 | - * @since 13.0.0 |
|
108 | - */ |
|
109 | - public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment { |
|
110 | - return new Attachment(new \Swift_Attachment($data, $filename, $contentType)); |
|
111 | - } |
|
102 | + /** |
|
103 | + * @param string|null $data |
|
104 | + * @param string|null $filename |
|
105 | + * @param string|null $contentType |
|
106 | + * @return IAttachment |
|
107 | + * @since 13.0.0 |
|
108 | + */ |
|
109 | + public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment { |
|
110 | + return new Attachment(new \Swift_Attachment($data, $filename, $contentType)); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * @param string $path |
|
115 | - * @param string|null $contentType |
|
116 | - * @return IAttachment |
|
117 | - * @since 13.0.0 |
|
118 | - */ |
|
119 | - public function createAttachmentFromPath(string $path, $contentType = null): IAttachment { |
|
120 | - return new Attachment(\Swift_Attachment::fromPath($path, $contentType)); |
|
121 | - } |
|
113 | + /** |
|
114 | + * @param string $path |
|
115 | + * @param string|null $contentType |
|
116 | + * @return IAttachment |
|
117 | + * @since 13.0.0 |
|
118 | + */ |
|
119 | + public function createAttachmentFromPath(string $path, $contentType = null): IAttachment { |
|
120 | + return new Attachment(\Swift_Attachment::fromPath($path, $contentType)); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Creates a new email template object |
|
125 | - * |
|
126 | - * @param string $emailId |
|
127 | - * @param array $data |
|
128 | - * @return IEMailTemplate |
|
129 | - * @since 12.0.0 |
|
130 | - */ |
|
131 | - public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate { |
|
132 | - $class = $this->config->getSystemValue('mail_template_class', ''); |
|
123 | + /** |
|
124 | + * Creates a new email template object |
|
125 | + * |
|
126 | + * @param string $emailId |
|
127 | + * @param array $data |
|
128 | + * @return IEMailTemplate |
|
129 | + * @since 12.0.0 |
|
130 | + */ |
|
131 | + public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate { |
|
132 | + $class = $this->config->getSystemValue('mail_template_class', ''); |
|
133 | 133 | |
134 | - if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) { |
|
135 | - return new $class( |
|
136 | - $this->defaults, |
|
137 | - $this->urlGenerator, |
|
138 | - $this->l10n, |
|
139 | - $emailId, |
|
140 | - $data |
|
141 | - ); |
|
142 | - } |
|
134 | + if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) { |
|
135 | + return new $class( |
|
136 | + $this->defaults, |
|
137 | + $this->urlGenerator, |
|
138 | + $this->l10n, |
|
139 | + $emailId, |
|
140 | + $data |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | |
144 | - return new EMailTemplate( |
|
145 | - $this->defaults, |
|
146 | - $this->urlGenerator, |
|
147 | - $this->l10n, |
|
148 | - $emailId, |
|
149 | - $data |
|
150 | - ); |
|
151 | - } |
|
144 | + return new EMailTemplate( |
|
145 | + $this->defaults, |
|
146 | + $this->urlGenerator, |
|
147 | + $this->l10n, |
|
148 | + $emailId, |
|
149 | + $data |
|
150 | + ); |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * Send the specified message. Also sets the from address to the value defined in config.php |
|
155 | - * if no-one has been passed. |
|
156 | - * |
|
157 | - * @param IMessage|Message $message Message to send |
|
158 | - * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and |
|
159 | - * therefore should be considered |
|
160 | - * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address |
|
161 | - * has been supplied.) |
|
162 | - */ |
|
163 | - public function send(IMessage $message): array { |
|
164 | - $debugMode = $this->config->getSystemValue('mail_smtpdebug', false); |
|
153 | + /** |
|
154 | + * Send the specified message. Also sets the from address to the value defined in config.php |
|
155 | + * if no-one has been passed. |
|
156 | + * |
|
157 | + * @param IMessage|Message $message Message to send |
|
158 | + * @return string[] Array with failed recipients. Be aware that this depends on the used mail backend and |
|
159 | + * therefore should be considered |
|
160 | + * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address |
|
161 | + * has been supplied.) |
|
162 | + */ |
|
163 | + public function send(IMessage $message): array { |
|
164 | + $debugMode = $this->config->getSystemValue('mail_smtpdebug', false); |
|
165 | 165 | |
166 | - if (empty($message->getFrom())) { |
|
167 | - $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName()) => $this->defaults->getName()]); |
|
168 | - } |
|
166 | + if (empty($message->getFrom())) { |
|
167 | + $message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName()) => $this->defaults->getName()]); |
|
168 | + } |
|
169 | 169 | |
170 | - $failedRecipients = []; |
|
170 | + $failedRecipients = []; |
|
171 | 171 | |
172 | - $mailer = $this->getInstance(); |
|
172 | + $mailer = $this->getInstance(); |
|
173 | 173 | |
174 | - // Enable logger if debug mode is enabled |
|
175 | - if($debugMode) { |
|
176 | - $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger(); |
|
177 | - $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger)); |
|
178 | - } |
|
174 | + // Enable logger if debug mode is enabled |
|
175 | + if($debugMode) { |
|
176 | + $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger(); |
|
177 | + $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger)); |
|
178 | + } |
|
179 | 179 | |
180 | - $mailer->send($message->getSwiftMessage(), $failedRecipients); |
|
180 | + $mailer->send($message->getSwiftMessage(), $failedRecipients); |
|
181 | 181 | |
182 | - // Debugging logging |
|
183 | - $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject()); |
|
184 | - $this->logger->debug($logMessage, ['app' => 'core']); |
|
185 | - if($debugMode && isset($mailLogger)) { |
|
186 | - $this->logger->debug($mailLogger->dump(), ['app' => 'core']); |
|
187 | - } |
|
182 | + // Debugging logging |
|
183 | + $logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject()); |
|
184 | + $this->logger->debug($logMessage, ['app' => 'core']); |
|
185 | + if($debugMode && isset($mailLogger)) { |
|
186 | + $this->logger->debug($mailLogger->dump(), ['app' => 'core']); |
|
187 | + } |
|
188 | 188 | |
189 | - return $failedRecipients; |
|
190 | - } |
|
189 | + return $failedRecipients; |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * Checks if an e-mail address is valid |
|
194 | - * |
|
195 | - * @param string $email Email address to be validated |
|
196 | - * @return bool True if the mail address is valid, false otherwise |
|
197 | - */ |
|
198 | - public function validateMailAddress(string $email): bool { |
|
199 | - $validator = new EmailValidator(); |
|
200 | - $validation = new RFCValidation(); |
|
192 | + /** |
|
193 | + * Checks if an e-mail address is valid |
|
194 | + * |
|
195 | + * @param string $email Email address to be validated |
|
196 | + * @return bool True if the mail address is valid, false otherwise |
|
197 | + */ |
|
198 | + public function validateMailAddress(string $email): bool { |
|
199 | + $validator = new EmailValidator(); |
|
200 | + $validation = new RFCValidation(); |
|
201 | 201 | |
202 | - return $validator->isValid($this->convertEmail($email), $validation); |
|
203 | - } |
|
202 | + return $validator->isValid($this->convertEmail($email), $validation); |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains |
|
207 | - * |
|
208 | - * FIXME: Remove this once SwiftMailer supports IDN |
|
209 | - * |
|
210 | - * @param string $email |
|
211 | - * @return string Converted mail address if `idn_to_ascii` exists |
|
212 | - */ |
|
213 | - protected function convertEmail(string $email): string { |
|
214 | - if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) { |
|
215 | - return $email; |
|
216 | - } |
|
205 | + /** |
|
206 | + * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains |
|
207 | + * |
|
208 | + * FIXME: Remove this once SwiftMailer supports IDN |
|
209 | + * |
|
210 | + * @param string $email |
|
211 | + * @return string Converted mail address if `idn_to_ascii` exists |
|
212 | + */ |
|
213 | + protected function convertEmail(string $email): string { |
|
214 | + if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) { |
|
215 | + return $email; |
|
216 | + } |
|
217 | 217 | |
218 | - list($name, $domain) = explode('@', $email, 2); |
|
219 | - $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46); |
|
220 | - return $name.'@'.$domain; |
|
221 | - } |
|
218 | + list($name, $domain) = explode('@', $email, 2); |
|
219 | + $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46); |
|
220 | + return $name.'@'.$domain; |
|
221 | + } |
|
222 | 222 | |
223 | - protected function getInstance(): \Swift_Mailer { |
|
224 | - if (!is_null($this->instance)) { |
|
225 | - return $this->instance; |
|
226 | - } |
|
223 | + protected function getInstance(): \Swift_Mailer { |
|
224 | + if (!is_null($this->instance)) { |
|
225 | + return $this->instance; |
|
226 | + } |
|
227 | 227 | |
228 | - $transport = null; |
|
228 | + $transport = null; |
|
229 | 229 | |
230 | - switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) { |
|
231 | - case 'sendmail': |
|
232 | - $transport = $this->getSendMailInstance(); |
|
233 | - break; |
|
234 | - case 'smtp': |
|
235 | - default: |
|
236 | - $transport = $this->getSmtpInstance(); |
|
237 | - break; |
|
238 | - } |
|
230 | + switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) { |
|
231 | + case 'sendmail': |
|
232 | + $transport = $this->getSendMailInstance(); |
|
233 | + break; |
|
234 | + case 'smtp': |
|
235 | + default: |
|
236 | + $transport = $this->getSmtpInstance(); |
|
237 | + break; |
|
238 | + } |
|
239 | 239 | |
240 | - return new \Swift_Mailer($transport); |
|
241 | - } |
|
240 | + return new \Swift_Mailer($transport); |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * Returns the SMTP transport |
|
245 | - * |
|
246 | - * @return \Swift_SmtpTransport |
|
247 | - */ |
|
248 | - protected function getSmtpInstance(): \Swift_SmtpTransport { |
|
249 | - $transport = new \Swift_SmtpTransport(); |
|
250 | - $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10)); |
|
251 | - $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1')); |
|
252 | - $transport->setPort($this->config->getSystemValue('mail_smtpport', 25)); |
|
253 | - if ($this->config->getSystemValue('mail_smtpauth', false)) { |
|
254 | - $transport->setUsername($this->config->getSystemValue('mail_smtpname', '')); |
|
255 | - $transport->setPassword($this->config->getSystemValue('mail_smtppassword', '')); |
|
256 | - $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN')); |
|
257 | - } |
|
258 | - $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', ''); |
|
259 | - if (!empty($smtpSecurity)) { |
|
260 | - $transport->setEncryption($smtpSecurity); |
|
261 | - } |
|
243 | + /** |
|
244 | + * Returns the SMTP transport |
|
245 | + * |
|
246 | + * @return \Swift_SmtpTransport |
|
247 | + */ |
|
248 | + protected function getSmtpInstance(): \Swift_SmtpTransport { |
|
249 | + $transport = new \Swift_SmtpTransport(); |
|
250 | + $transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10)); |
|
251 | + $transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1')); |
|
252 | + $transport->setPort($this->config->getSystemValue('mail_smtpport', 25)); |
|
253 | + if ($this->config->getSystemValue('mail_smtpauth', false)) { |
|
254 | + $transport->setUsername($this->config->getSystemValue('mail_smtpname', '')); |
|
255 | + $transport->setPassword($this->config->getSystemValue('mail_smtppassword', '')); |
|
256 | + $transport->setAuthMode($this->config->getSystemValue('mail_smtpauthtype', 'LOGIN')); |
|
257 | + } |
|
258 | + $smtpSecurity = $this->config->getSystemValue('mail_smtpsecure', ''); |
|
259 | + if (!empty($smtpSecurity)) { |
|
260 | + $transport->setEncryption($smtpSecurity); |
|
261 | + } |
|
262 | 262 | |
263 | - return $transport; |
|
264 | - } |
|
263 | + return $transport; |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Returns the sendmail transport |
|
268 | - * |
|
269 | - * @return \Swift_SendmailTransport |
|
270 | - */ |
|
271 | - protected function getSendMailInstance(): \Swift_SendmailTransport { |
|
272 | - switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) { |
|
273 | - case 'qmail': |
|
274 | - $binaryPath = '/var/qmail/bin/sendmail'; |
|
275 | - break; |
|
276 | - default: |
|
277 | - $binaryPath = '/usr/sbin/sendmail'; |
|
278 | - break; |
|
279 | - } |
|
266 | + /** |
|
267 | + * Returns the sendmail transport |
|
268 | + * |
|
269 | + * @return \Swift_SendmailTransport |
|
270 | + */ |
|
271 | + protected function getSendMailInstance(): \Swift_SendmailTransport { |
|
272 | + switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) { |
|
273 | + case 'qmail': |
|
274 | + $binaryPath = '/var/qmail/bin/sendmail'; |
|
275 | + break; |
|
276 | + default: |
|
277 | + $binaryPath = '/usr/sbin/sendmail'; |
|
278 | + break; |
|
279 | + } |
|
280 | 280 | |
281 | - return new \Swift_SendmailTransport($binaryPath . ' -bs'); |
|
282 | - } |
|
281 | + return new \Swift_SendmailTransport($binaryPath . ' -bs'); |
|
282 | + } |
|
283 | 283 | } |
@@ -59,289 +59,289 @@ discard block |
||
59 | 59 | * @package OC\Settings\Controller |
60 | 60 | */ |
61 | 61 | class CheckSetupController extends Controller { |
62 | - /** @var IConfig */ |
|
63 | - private $config; |
|
64 | - /** @var IClientService */ |
|
65 | - private $clientService; |
|
66 | - /** @var \OC_Util */ |
|
67 | - private $util; |
|
68 | - /** @var IURLGenerator */ |
|
69 | - private $urlGenerator; |
|
70 | - /** @var IL10N */ |
|
71 | - private $l10n; |
|
72 | - /** @var Checker */ |
|
73 | - private $checker; |
|
74 | - /** @var ILogger */ |
|
75 | - private $logger; |
|
76 | - /** @var EventDispatcherInterface */ |
|
77 | - private $dispatcher; |
|
78 | - /** @var IDBConnection|Connection */ |
|
79 | - private $db; |
|
80 | - /** @var ILockingProvider */ |
|
81 | - private $lockingProvider; |
|
82 | - /** @var IDateTimeFormatter */ |
|
83 | - private $dateTimeFormatter; |
|
84 | - |
|
85 | - public function __construct($AppName, |
|
86 | - IRequest $request, |
|
87 | - IConfig $config, |
|
88 | - IClientService $clientService, |
|
89 | - IURLGenerator $urlGenerator, |
|
90 | - \OC_Util $util, |
|
91 | - IL10N $l10n, |
|
92 | - Checker $checker, |
|
93 | - ILogger $logger, |
|
94 | - EventDispatcherInterface $dispatcher, |
|
95 | - IDBConnection $db, |
|
96 | - ILockingProvider $lockingProvider, |
|
97 | - IDateTimeFormatter $dateTimeFormatter) { |
|
98 | - parent::__construct($AppName, $request); |
|
99 | - $this->config = $config; |
|
100 | - $this->clientService = $clientService; |
|
101 | - $this->util = $util; |
|
102 | - $this->urlGenerator = $urlGenerator; |
|
103 | - $this->l10n = $l10n; |
|
104 | - $this->checker = $checker; |
|
105 | - $this->logger = $logger; |
|
106 | - $this->dispatcher = $dispatcher; |
|
107 | - $this->db = $db; |
|
108 | - $this->lockingProvider = $lockingProvider; |
|
109 | - $this->dateTimeFormatter = $dateTimeFormatter; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Checks if the server can connect to the internet using HTTPS and HTTP |
|
114 | - * @return bool |
|
115 | - */ |
|
116 | - private function isInternetConnectionWorking() { |
|
117 | - if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
118 | - return false; |
|
119 | - } |
|
120 | - |
|
121 | - $siteArray = ['www.nextcloud.com', |
|
122 | - 'www.startpage.com', |
|
123 | - 'www.eff.org', |
|
124 | - 'www.edri.org', |
|
125 | - ]; |
|
126 | - |
|
127 | - foreach($siteArray as $site) { |
|
128 | - if ($this->isSiteReachable($site)) { |
|
129 | - return true; |
|
130 | - } |
|
131 | - } |
|
132 | - return false; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
|
137 | - * @return bool |
|
138 | - */ |
|
139 | - private function isSiteReachable($sitename) { |
|
140 | - $httpSiteName = 'http://' . $sitename . '/'; |
|
141 | - $httpsSiteName = 'https://' . $sitename . '/'; |
|
142 | - |
|
143 | - try { |
|
144 | - $client = $this->clientService->newClient(); |
|
145 | - $client->get($httpSiteName); |
|
146 | - $client->get($httpsSiteName); |
|
147 | - } catch (\Exception $e) { |
|
148 | - $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
149 | - return false; |
|
150 | - } |
|
151 | - return true; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Checks whether a local memcache is installed or not |
|
156 | - * @return bool |
|
157 | - */ |
|
158 | - private function isMemcacheConfigured() { |
|
159 | - return $this->config->getSystemValue('memcache.local', null) !== null; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Whether /dev/urandom is available to the PHP controller |
|
164 | - * |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - private function isUrandomAvailable() { |
|
168 | - if(@file_exists('/dev/urandom')) { |
|
169 | - $file = fopen('/dev/urandom', 'rb'); |
|
170 | - if($file) { |
|
171 | - fclose($file); |
|
172 | - return true; |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - return false; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Public for the sake of unit-testing |
|
181 | - * |
|
182 | - * @return array |
|
183 | - */ |
|
184 | - protected function getCurlVersion() { |
|
185 | - return curl_version(); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
190 | - * have multiple bugs which likely lead to problems in combination with |
|
191 | - * functionality required by ownCloud such as SNI. |
|
192 | - * |
|
193 | - * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
194 | - * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - private function isUsedTlsLibOutdated() { |
|
198 | - // Don't run check when: |
|
199 | - // 1. Server has `has_internet_connection` set to false |
|
200 | - // 2. AppStore AND S2S is disabled |
|
201 | - if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
202 | - return ''; |
|
203 | - } |
|
204 | - if(!$this->config->getSystemValue('appstoreenabled', true) |
|
205 | - && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
206 | - && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
207 | - return ''; |
|
208 | - } |
|
209 | - |
|
210 | - $versionString = $this->getCurlVersion(); |
|
211 | - if(isset($versionString['ssl_version'])) { |
|
212 | - $versionString = $versionString['ssl_version']; |
|
213 | - } else { |
|
214 | - return ''; |
|
215 | - } |
|
216 | - |
|
217 | - $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
218 | - if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
219 | - $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
220 | - } |
|
221 | - |
|
222 | - // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
223 | - if(strpos($versionString, 'OpenSSL/') === 0) { |
|
224 | - $majorVersion = substr($versionString, 8, 5); |
|
225 | - $patchRelease = substr($versionString, 13, 6); |
|
226 | - |
|
227 | - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
228 | - ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
229 | - return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - // Check if NSS and perform heuristic check |
|
234 | - if(strpos($versionString, 'NSS/') === 0) { |
|
235 | - try { |
|
236 | - $firstClient = $this->clientService->newClient(); |
|
237 | - $firstClient->get('https://nextcloud.com/'); |
|
238 | - |
|
239 | - $secondClient = $this->clientService->newClient(); |
|
240 | - $secondClient->get('https://nextcloud.com/'); |
|
241 | - } catch (ClientException $e) { |
|
242 | - if($e->getResponse()->getStatusCode() === 400) { |
|
243 | - return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - |
|
248 | - return ''; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Whether the version is outdated |
|
253 | - * |
|
254 | - * @return bool |
|
255 | - */ |
|
256 | - protected function isPhpOutdated() { |
|
257 | - if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
258 | - return true; |
|
259 | - } |
|
260 | - |
|
261 | - return false; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Whether the php version is still supported (at time of release) |
|
266 | - * according to: https://secure.php.net/supported-versions.php |
|
267 | - * |
|
268 | - * @return array |
|
269 | - */ |
|
270 | - private function isPhpSupported() { |
|
271 | - return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Check if the reverse proxy configuration is working as expected |
|
276 | - * |
|
277 | - * @return bool |
|
278 | - */ |
|
279 | - private function forwardedForHeadersWorking() { |
|
280 | - $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); |
|
281 | - $remoteAddress = $this->request->getRemoteAddress(); |
|
282 | - |
|
283 | - if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
284 | - return false; |
|
285 | - } |
|
286 | - |
|
287 | - // either not enabled or working correctly |
|
288 | - return true; |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Checks if the correct memcache module for PHP is installed. Only |
|
293 | - * fails if memcached is configured and the working module is not installed. |
|
294 | - * |
|
295 | - * @return bool |
|
296 | - */ |
|
297 | - private function isCorrectMemcachedPHPModuleInstalled() { |
|
298 | - if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
299 | - return true; |
|
300 | - } |
|
301 | - |
|
302 | - // there are two different memcached modules for PHP |
|
303 | - // we only support memcached and not memcache |
|
304 | - // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
305 | - return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Checks if set_time_limit is not disabled. |
|
310 | - * |
|
311 | - * @return bool |
|
312 | - */ |
|
313 | - private function isSettimelimitAvailable() { |
|
314 | - if (function_exists('set_time_limit') |
|
315 | - && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
316 | - return true; |
|
317 | - } |
|
318 | - |
|
319 | - return false; |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * @return RedirectResponse |
|
324 | - */ |
|
325 | - public function rescanFailedIntegrityCheck() { |
|
326 | - $this->checker->runInstanceVerification(); |
|
327 | - return new RedirectResponse( |
|
328 | - $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
329 | - ); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * @NoCSRFRequired |
|
334 | - * @return DataResponse |
|
335 | - */ |
|
336 | - public function getFailedIntegrityCheckFiles() { |
|
337 | - if(!$this->checker->isCodeCheckEnforced()) { |
|
338 | - return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
339 | - } |
|
340 | - |
|
341 | - $completeResults = $this->checker->getResults(); |
|
342 | - |
|
343 | - if(!empty($completeResults)) { |
|
344 | - $formattedTextResponse = 'Technical information |
|
62 | + /** @var IConfig */ |
|
63 | + private $config; |
|
64 | + /** @var IClientService */ |
|
65 | + private $clientService; |
|
66 | + /** @var \OC_Util */ |
|
67 | + private $util; |
|
68 | + /** @var IURLGenerator */ |
|
69 | + private $urlGenerator; |
|
70 | + /** @var IL10N */ |
|
71 | + private $l10n; |
|
72 | + /** @var Checker */ |
|
73 | + private $checker; |
|
74 | + /** @var ILogger */ |
|
75 | + private $logger; |
|
76 | + /** @var EventDispatcherInterface */ |
|
77 | + private $dispatcher; |
|
78 | + /** @var IDBConnection|Connection */ |
|
79 | + private $db; |
|
80 | + /** @var ILockingProvider */ |
|
81 | + private $lockingProvider; |
|
82 | + /** @var IDateTimeFormatter */ |
|
83 | + private $dateTimeFormatter; |
|
84 | + |
|
85 | + public function __construct($AppName, |
|
86 | + IRequest $request, |
|
87 | + IConfig $config, |
|
88 | + IClientService $clientService, |
|
89 | + IURLGenerator $urlGenerator, |
|
90 | + \OC_Util $util, |
|
91 | + IL10N $l10n, |
|
92 | + Checker $checker, |
|
93 | + ILogger $logger, |
|
94 | + EventDispatcherInterface $dispatcher, |
|
95 | + IDBConnection $db, |
|
96 | + ILockingProvider $lockingProvider, |
|
97 | + IDateTimeFormatter $dateTimeFormatter) { |
|
98 | + parent::__construct($AppName, $request); |
|
99 | + $this->config = $config; |
|
100 | + $this->clientService = $clientService; |
|
101 | + $this->util = $util; |
|
102 | + $this->urlGenerator = $urlGenerator; |
|
103 | + $this->l10n = $l10n; |
|
104 | + $this->checker = $checker; |
|
105 | + $this->logger = $logger; |
|
106 | + $this->dispatcher = $dispatcher; |
|
107 | + $this->db = $db; |
|
108 | + $this->lockingProvider = $lockingProvider; |
|
109 | + $this->dateTimeFormatter = $dateTimeFormatter; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Checks if the server can connect to the internet using HTTPS and HTTP |
|
114 | + * @return bool |
|
115 | + */ |
|
116 | + private function isInternetConnectionWorking() { |
|
117 | + if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
118 | + return false; |
|
119 | + } |
|
120 | + |
|
121 | + $siteArray = ['www.nextcloud.com', |
|
122 | + 'www.startpage.com', |
|
123 | + 'www.eff.org', |
|
124 | + 'www.edri.org', |
|
125 | + ]; |
|
126 | + |
|
127 | + foreach($siteArray as $site) { |
|
128 | + if ($this->isSiteReachable($site)) { |
|
129 | + return true; |
|
130 | + } |
|
131 | + } |
|
132 | + return false; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
|
137 | + * @return bool |
|
138 | + */ |
|
139 | + private function isSiteReachable($sitename) { |
|
140 | + $httpSiteName = 'http://' . $sitename . '/'; |
|
141 | + $httpsSiteName = 'https://' . $sitename . '/'; |
|
142 | + |
|
143 | + try { |
|
144 | + $client = $this->clientService->newClient(); |
|
145 | + $client->get($httpSiteName); |
|
146 | + $client->get($httpsSiteName); |
|
147 | + } catch (\Exception $e) { |
|
148 | + $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
149 | + return false; |
|
150 | + } |
|
151 | + return true; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Checks whether a local memcache is installed or not |
|
156 | + * @return bool |
|
157 | + */ |
|
158 | + private function isMemcacheConfigured() { |
|
159 | + return $this->config->getSystemValue('memcache.local', null) !== null; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Whether /dev/urandom is available to the PHP controller |
|
164 | + * |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + private function isUrandomAvailable() { |
|
168 | + if(@file_exists('/dev/urandom')) { |
|
169 | + $file = fopen('/dev/urandom', 'rb'); |
|
170 | + if($file) { |
|
171 | + fclose($file); |
|
172 | + return true; |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + return false; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Public for the sake of unit-testing |
|
181 | + * |
|
182 | + * @return array |
|
183 | + */ |
|
184 | + protected function getCurlVersion() { |
|
185 | + return curl_version(); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
190 | + * have multiple bugs which likely lead to problems in combination with |
|
191 | + * functionality required by ownCloud such as SNI. |
|
192 | + * |
|
193 | + * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
194 | + * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + private function isUsedTlsLibOutdated() { |
|
198 | + // Don't run check when: |
|
199 | + // 1. Server has `has_internet_connection` set to false |
|
200 | + // 2. AppStore AND S2S is disabled |
|
201 | + if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
202 | + return ''; |
|
203 | + } |
|
204 | + if(!$this->config->getSystemValue('appstoreenabled', true) |
|
205 | + && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
206 | + && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
207 | + return ''; |
|
208 | + } |
|
209 | + |
|
210 | + $versionString = $this->getCurlVersion(); |
|
211 | + if(isset($versionString['ssl_version'])) { |
|
212 | + $versionString = $versionString['ssl_version']; |
|
213 | + } else { |
|
214 | + return ''; |
|
215 | + } |
|
216 | + |
|
217 | + $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
218 | + if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
219 | + $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
220 | + } |
|
221 | + |
|
222 | + // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
223 | + if(strpos($versionString, 'OpenSSL/') === 0) { |
|
224 | + $majorVersion = substr($versionString, 8, 5); |
|
225 | + $patchRelease = substr($versionString, 13, 6); |
|
226 | + |
|
227 | + if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
228 | + ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
229 | + return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + // Check if NSS and perform heuristic check |
|
234 | + if(strpos($versionString, 'NSS/') === 0) { |
|
235 | + try { |
|
236 | + $firstClient = $this->clientService->newClient(); |
|
237 | + $firstClient->get('https://nextcloud.com/'); |
|
238 | + |
|
239 | + $secondClient = $this->clientService->newClient(); |
|
240 | + $secondClient->get('https://nextcloud.com/'); |
|
241 | + } catch (ClientException $e) { |
|
242 | + if($e->getResponse()->getStatusCode() === 400) { |
|
243 | + return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + |
|
248 | + return ''; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Whether the version is outdated |
|
253 | + * |
|
254 | + * @return bool |
|
255 | + */ |
|
256 | + protected function isPhpOutdated() { |
|
257 | + if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
258 | + return true; |
|
259 | + } |
|
260 | + |
|
261 | + return false; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Whether the php version is still supported (at time of release) |
|
266 | + * according to: https://secure.php.net/supported-versions.php |
|
267 | + * |
|
268 | + * @return array |
|
269 | + */ |
|
270 | + private function isPhpSupported() { |
|
271 | + return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Check if the reverse proxy configuration is working as expected |
|
276 | + * |
|
277 | + * @return bool |
|
278 | + */ |
|
279 | + private function forwardedForHeadersWorking() { |
|
280 | + $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); |
|
281 | + $remoteAddress = $this->request->getRemoteAddress(); |
|
282 | + |
|
283 | + if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
284 | + return false; |
|
285 | + } |
|
286 | + |
|
287 | + // either not enabled or working correctly |
|
288 | + return true; |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Checks if the correct memcache module for PHP is installed. Only |
|
293 | + * fails if memcached is configured and the working module is not installed. |
|
294 | + * |
|
295 | + * @return bool |
|
296 | + */ |
|
297 | + private function isCorrectMemcachedPHPModuleInstalled() { |
|
298 | + if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
299 | + return true; |
|
300 | + } |
|
301 | + |
|
302 | + // there are two different memcached modules for PHP |
|
303 | + // we only support memcached and not memcache |
|
304 | + // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
305 | + return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Checks if set_time_limit is not disabled. |
|
310 | + * |
|
311 | + * @return bool |
|
312 | + */ |
|
313 | + private function isSettimelimitAvailable() { |
|
314 | + if (function_exists('set_time_limit') |
|
315 | + && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
316 | + return true; |
|
317 | + } |
|
318 | + |
|
319 | + return false; |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * @return RedirectResponse |
|
324 | + */ |
|
325 | + public function rescanFailedIntegrityCheck() { |
|
326 | + $this->checker->runInstanceVerification(); |
|
327 | + return new RedirectResponse( |
|
328 | + $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
329 | + ); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * @NoCSRFRequired |
|
334 | + * @return DataResponse |
|
335 | + */ |
|
336 | + public function getFailedIntegrityCheckFiles() { |
|
337 | + if(!$this->checker->isCodeCheckEnforced()) { |
|
338 | + return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
339 | + } |
|
340 | + |
|
341 | + $completeResults = $this->checker->getResults(); |
|
342 | + |
|
343 | + if(!empty($completeResults)) { |
|
344 | + $formattedTextResponse = 'Technical information |
|
345 | 345 | ===================== |
346 | 346 | The following list covers which files have failed the integrity check. Please read |
347 | 347 | the previous linked documentation to learn more about the errors and how to fix |
@@ -350,220 +350,220 @@ discard block |
||
350 | 350 | Results |
351 | 351 | ======= |
352 | 352 | '; |
353 | - foreach($completeResults as $context => $contextResult) { |
|
354 | - $formattedTextResponse .= "- $context\n"; |
|
355 | - |
|
356 | - foreach($contextResult as $category => $result) { |
|
357 | - $formattedTextResponse .= "\t- $category\n"; |
|
358 | - if($category !== 'EXCEPTION') { |
|
359 | - foreach ($result as $key => $results) { |
|
360 | - $formattedTextResponse .= "\t\t- $key\n"; |
|
361 | - } |
|
362 | - } else { |
|
363 | - foreach ($result as $key => $results) { |
|
364 | - $formattedTextResponse .= "\t\t- $results\n"; |
|
365 | - } |
|
366 | - } |
|
367 | - |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - $formattedTextResponse .= ' |
|
353 | + foreach($completeResults as $context => $contextResult) { |
|
354 | + $formattedTextResponse .= "- $context\n"; |
|
355 | + |
|
356 | + foreach($contextResult as $category => $result) { |
|
357 | + $formattedTextResponse .= "\t- $category\n"; |
|
358 | + if($category !== 'EXCEPTION') { |
|
359 | + foreach ($result as $key => $results) { |
|
360 | + $formattedTextResponse .= "\t\t- $key\n"; |
|
361 | + } |
|
362 | + } else { |
|
363 | + foreach ($result as $key => $results) { |
|
364 | + $formattedTextResponse .= "\t\t- $results\n"; |
|
365 | + } |
|
366 | + } |
|
367 | + |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + $formattedTextResponse .= ' |
|
372 | 372 | Raw output |
373 | 373 | ========== |
374 | 374 | '; |
375 | - $formattedTextResponse .= print_r($completeResults, true); |
|
376 | - } else { |
|
377 | - $formattedTextResponse = 'No errors have been found.'; |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - $response = new DataDisplayResponse( |
|
382 | - $formattedTextResponse, |
|
383 | - Http::STATUS_OK, |
|
384 | - [ |
|
385 | - 'Content-Type' => 'text/plain', |
|
386 | - ] |
|
387 | - ); |
|
388 | - |
|
389 | - return $response; |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * Checks whether a PHP opcache is properly set up |
|
394 | - * @return bool |
|
395 | - */ |
|
396 | - protected function isOpcacheProperlySetup() { |
|
397 | - $iniWrapper = new IniGetWrapper(); |
|
398 | - |
|
399 | - $isOpcacheProperlySetUp = true; |
|
400 | - |
|
401 | - if(!$iniWrapper->getBool('opcache.enable')) { |
|
402 | - $isOpcacheProperlySetUp = false; |
|
403 | - } |
|
404 | - |
|
405 | - if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
406 | - $isOpcacheProperlySetUp = false; |
|
407 | - } |
|
408 | - |
|
409 | - if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
410 | - $isOpcacheProperlySetUp = false; |
|
411 | - } |
|
412 | - |
|
413 | - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
414 | - $isOpcacheProperlySetUp = false; |
|
415 | - } |
|
416 | - |
|
417 | - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
418 | - $isOpcacheProperlySetUp = false; |
|
419 | - } |
|
420 | - |
|
421 | - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
422 | - $isOpcacheProperlySetUp = false; |
|
423 | - } |
|
424 | - |
|
425 | - return $isOpcacheProperlySetUp; |
|
426 | - } |
|
427 | - |
|
428 | - /** |
|
429 | - * Check if the required FreeType functions are present |
|
430 | - * @return bool |
|
431 | - */ |
|
432 | - protected function hasFreeTypeSupport() { |
|
433 | - return function_exists('imagettfbbox') && function_exists('imagettftext'); |
|
434 | - } |
|
435 | - |
|
436 | - protected function hasMissingIndexes(): array { |
|
437 | - $indexInfo = new MissingIndexInformation(); |
|
438 | - // Dispatch event so apps can also hint for pending index updates if needed |
|
439 | - $event = new GenericEvent($indexInfo); |
|
440 | - $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event); |
|
441 | - |
|
442 | - return $indexInfo->getListOfMissingIndexes(); |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * warn if outdated version of a memcache module is used |
|
447 | - */ |
|
448 | - protected function getOutdatedCaches(): array { |
|
449 | - $caches = [ |
|
450 | - 'apcu' => ['name' => 'APCu', 'version' => '4.0.6'], |
|
451 | - 'redis' => ['name' => 'Redis', 'version' => '2.2.5'], |
|
452 | - ]; |
|
453 | - $outdatedCaches = []; |
|
454 | - foreach ($caches as $php_module => $data) { |
|
455 | - $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
|
456 | - if ($isOutdated) { |
|
457 | - $outdatedCaches[] = $data; |
|
458 | - } |
|
459 | - } |
|
460 | - |
|
461 | - return $outdatedCaches; |
|
462 | - } |
|
463 | - |
|
464 | - protected function isSqliteUsed() { |
|
465 | - return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false; |
|
466 | - } |
|
467 | - |
|
468 | - protected function isReadOnlyConfig(): bool { |
|
469 | - return \OC_Helper::isReadOnlyConfigEnabled(); |
|
470 | - } |
|
471 | - |
|
472 | - protected function hasValidTransactionIsolationLevel(): bool { |
|
473 | - try { |
|
474 | - if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { |
|
475 | - return true; |
|
476 | - } |
|
477 | - |
|
478 | - return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED; |
|
479 | - } catch (DBALException $e) { |
|
480 | - // ignore |
|
481 | - } |
|
482 | - |
|
483 | - return true; |
|
484 | - } |
|
485 | - |
|
486 | - protected function hasFileinfoInstalled(): bool { |
|
487 | - return \OC_Util::fileInfoLoaded(); |
|
488 | - } |
|
489 | - |
|
490 | - protected function hasWorkingFileLocking(): bool { |
|
491 | - return !($this->lockingProvider instanceof NoopLockingProvider); |
|
492 | - } |
|
493 | - |
|
494 | - protected function getSuggestedOverwriteCliURL(): string { |
|
495 | - $suggestedOverwriteCliUrl = ''; |
|
496 | - if ($this->config->getSystemValue('overwrite.cli.url', '') === '') { |
|
497 | - $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; |
|
498 | - if (!$this->config->getSystemValue('config_is_read_only', false)) { |
|
499 | - // Set the overwrite URL when it was not set yet. |
|
500 | - $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl); |
|
501 | - $suggestedOverwriteCliUrl = ''; |
|
502 | - } |
|
503 | - } |
|
504 | - return $suggestedOverwriteCliUrl; |
|
505 | - } |
|
506 | - |
|
507 | - protected function getLastCronInfo(): array { |
|
508 | - $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0); |
|
509 | - return [ |
|
510 | - 'diffInSeconds' => time() - $lastCronRun, |
|
511 | - 'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun), |
|
512 | - 'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs', |
|
513 | - ]; |
|
514 | - } |
|
515 | - |
|
516 | - protected function getCronErrors() { |
|
517 | - $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true); |
|
518 | - |
|
519 | - if (is_array($errors)) { |
|
520 | - return $errors; |
|
521 | - } |
|
522 | - |
|
523 | - return []; |
|
524 | - } |
|
525 | - |
|
526 | - protected function isPhpMailerUsed(): bool { |
|
527 | - return $this->config->getSystemValue('mail_smtpmode', 'php') === 'php'; |
|
528 | - } |
|
529 | - |
|
530 | - /** |
|
531 | - * @return DataResponse |
|
532 | - */ |
|
533 | - public function check() { |
|
534 | - return new DataResponse( |
|
535 | - [ |
|
536 | - 'isGetenvServerWorking' => !empty(getenv('PATH')), |
|
537 | - 'isReadOnlyConfig' => $this->isReadOnlyConfig(), |
|
538 | - 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(), |
|
539 | - 'outdatedCaches' => $this->getOutdatedCaches(), |
|
540 | - 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(), |
|
541 | - 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(), |
|
542 | - 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(), |
|
543 | - 'cronInfo' => $this->getLastCronInfo(), |
|
544 | - 'cronErrors' => $this->getCronErrors(), |
|
545 | - 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
546 | - 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
547 | - 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
548 | - 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
549 | - 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
550 | - 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
551 | - 'phpSupported' => $this->isPhpSupported(), |
|
552 | - 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
553 | - 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
554 | - 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
555 | - 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
556 | - 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
557 | - 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
558 | - 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
559 | - 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
560 | - 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), |
|
561 | - 'missingIndexes' => $this->hasMissingIndexes(), |
|
562 | - 'isSqliteUsed' => $this->isSqliteUsed(), |
|
563 | - 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), |
|
564 | - 'isPhpMailerUsed' => $this->isPhpMailerUsed(), |
|
565 | - 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin') |
|
566 | - ] |
|
567 | - ); |
|
568 | - } |
|
375 | + $formattedTextResponse .= print_r($completeResults, true); |
|
376 | + } else { |
|
377 | + $formattedTextResponse = 'No errors have been found.'; |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + $response = new DataDisplayResponse( |
|
382 | + $formattedTextResponse, |
|
383 | + Http::STATUS_OK, |
|
384 | + [ |
|
385 | + 'Content-Type' => 'text/plain', |
|
386 | + ] |
|
387 | + ); |
|
388 | + |
|
389 | + return $response; |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * Checks whether a PHP opcache is properly set up |
|
394 | + * @return bool |
|
395 | + */ |
|
396 | + protected function isOpcacheProperlySetup() { |
|
397 | + $iniWrapper = new IniGetWrapper(); |
|
398 | + |
|
399 | + $isOpcacheProperlySetUp = true; |
|
400 | + |
|
401 | + if(!$iniWrapper->getBool('opcache.enable')) { |
|
402 | + $isOpcacheProperlySetUp = false; |
|
403 | + } |
|
404 | + |
|
405 | + if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
406 | + $isOpcacheProperlySetUp = false; |
|
407 | + } |
|
408 | + |
|
409 | + if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
410 | + $isOpcacheProperlySetUp = false; |
|
411 | + } |
|
412 | + |
|
413 | + if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
414 | + $isOpcacheProperlySetUp = false; |
|
415 | + } |
|
416 | + |
|
417 | + if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
418 | + $isOpcacheProperlySetUp = false; |
|
419 | + } |
|
420 | + |
|
421 | + if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
422 | + $isOpcacheProperlySetUp = false; |
|
423 | + } |
|
424 | + |
|
425 | + return $isOpcacheProperlySetUp; |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * Check if the required FreeType functions are present |
|
430 | + * @return bool |
|
431 | + */ |
|
432 | + protected function hasFreeTypeSupport() { |
|
433 | + return function_exists('imagettfbbox') && function_exists('imagettftext'); |
|
434 | + } |
|
435 | + |
|
436 | + protected function hasMissingIndexes(): array { |
|
437 | + $indexInfo = new MissingIndexInformation(); |
|
438 | + // Dispatch event so apps can also hint for pending index updates if needed |
|
439 | + $event = new GenericEvent($indexInfo); |
|
440 | + $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event); |
|
441 | + |
|
442 | + return $indexInfo->getListOfMissingIndexes(); |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * warn if outdated version of a memcache module is used |
|
447 | + */ |
|
448 | + protected function getOutdatedCaches(): array { |
|
449 | + $caches = [ |
|
450 | + 'apcu' => ['name' => 'APCu', 'version' => '4.0.6'], |
|
451 | + 'redis' => ['name' => 'Redis', 'version' => '2.2.5'], |
|
452 | + ]; |
|
453 | + $outdatedCaches = []; |
|
454 | + foreach ($caches as $php_module => $data) { |
|
455 | + $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
|
456 | + if ($isOutdated) { |
|
457 | + $outdatedCaches[] = $data; |
|
458 | + } |
|
459 | + } |
|
460 | + |
|
461 | + return $outdatedCaches; |
|
462 | + } |
|
463 | + |
|
464 | + protected function isSqliteUsed() { |
|
465 | + return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false; |
|
466 | + } |
|
467 | + |
|
468 | + protected function isReadOnlyConfig(): bool { |
|
469 | + return \OC_Helper::isReadOnlyConfigEnabled(); |
|
470 | + } |
|
471 | + |
|
472 | + protected function hasValidTransactionIsolationLevel(): bool { |
|
473 | + try { |
|
474 | + if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { |
|
475 | + return true; |
|
476 | + } |
|
477 | + |
|
478 | + return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED; |
|
479 | + } catch (DBALException $e) { |
|
480 | + // ignore |
|
481 | + } |
|
482 | + |
|
483 | + return true; |
|
484 | + } |
|
485 | + |
|
486 | + protected function hasFileinfoInstalled(): bool { |
|
487 | + return \OC_Util::fileInfoLoaded(); |
|
488 | + } |
|
489 | + |
|
490 | + protected function hasWorkingFileLocking(): bool { |
|
491 | + return !($this->lockingProvider instanceof NoopLockingProvider); |
|
492 | + } |
|
493 | + |
|
494 | + protected function getSuggestedOverwriteCliURL(): string { |
|
495 | + $suggestedOverwriteCliUrl = ''; |
|
496 | + if ($this->config->getSystemValue('overwrite.cli.url', '') === '') { |
|
497 | + $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; |
|
498 | + if (!$this->config->getSystemValue('config_is_read_only', false)) { |
|
499 | + // Set the overwrite URL when it was not set yet. |
|
500 | + $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl); |
|
501 | + $suggestedOverwriteCliUrl = ''; |
|
502 | + } |
|
503 | + } |
|
504 | + return $suggestedOverwriteCliUrl; |
|
505 | + } |
|
506 | + |
|
507 | + protected function getLastCronInfo(): array { |
|
508 | + $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0); |
|
509 | + return [ |
|
510 | + 'diffInSeconds' => time() - $lastCronRun, |
|
511 | + 'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun), |
|
512 | + 'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs', |
|
513 | + ]; |
|
514 | + } |
|
515 | + |
|
516 | + protected function getCronErrors() { |
|
517 | + $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true); |
|
518 | + |
|
519 | + if (is_array($errors)) { |
|
520 | + return $errors; |
|
521 | + } |
|
522 | + |
|
523 | + return []; |
|
524 | + } |
|
525 | + |
|
526 | + protected function isPhpMailerUsed(): bool { |
|
527 | + return $this->config->getSystemValue('mail_smtpmode', 'php') === 'php'; |
|
528 | + } |
|
529 | + |
|
530 | + /** |
|
531 | + * @return DataResponse |
|
532 | + */ |
|
533 | + public function check() { |
|
534 | + return new DataResponse( |
|
535 | + [ |
|
536 | + 'isGetenvServerWorking' => !empty(getenv('PATH')), |
|
537 | + 'isReadOnlyConfig' => $this->isReadOnlyConfig(), |
|
538 | + 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(), |
|
539 | + 'outdatedCaches' => $this->getOutdatedCaches(), |
|
540 | + 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(), |
|
541 | + 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(), |
|
542 | + 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(), |
|
543 | + 'cronInfo' => $this->getLastCronInfo(), |
|
544 | + 'cronErrors' => $this->getCronErrors(), |
|
545 | + 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
546 | + 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
547 | + 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
548 | + 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
549 | + 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
550 | + 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
551 | + 'phpSupported' => $this->isPhpSupported(), |
|
552 | + 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
553 | + 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
554 | + 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
555 | + 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
556 | + 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
557 | + 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
558 | + 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
559 | + 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
560 | + 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), |
|
561 | + 'missingIndexes' => $this->hasMissingIndexes(), |
|
562 | + 'isSqliteUsed' => $this->isSqliteUsed(), |
|
563 | + 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), |
|
564 | + 'isPhpMailerUsed' => $this->isPhpMailerUsed(), |
|
565 | + 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin') |
|
566 | + ] |
|
567 | + ); |
|
568 | + } |
|
569 | 569 | } |