@@ -36,142 +36,142 @@ |
||
| 36 | 36 | use OCP\IConfig; |
| 37 | 37 | |
| 38 | 38 | class IconController extends Controller { |
| 39 | - /** @var ThemingDefaults */ |
|
| 40 | - private $themingDefaults; |
|
| 41 | - /** @var Util */ |
|
| 42 | - private $util; |
|
| 43 | - /** @var ITimeFactory */ |
|
| 44 | - private $timeFactory; |
|
| 45 | - /** @var IConfig */ |
|
| 46 | - private $config; |
|
| 47 | - /** @var IconBuilder */ |
|
| 48 | - private $iconBuilder; |
|
| 49 | - /** @var ImageManager */ |
|
| 50 | - private $imageManager; |
|
| 39 | + /** @var ThemingDefaults */ |
|
| 40 | + private $themingDefaults; |
|
| 41 | + /** @var Util */ |
|
| 42 | + private $util; |
|
| 43 | + /** @var ITimeFactory */ |
|
| 44 | + private $timeFactory; |
|
| 45 | + /** @var IConfig */ |
|
| 46 | + private $config; |
|
| 47 | + /** @var IconBuilder */ |
|
| 48 | + private $iconBuilder; |
|
| 49 | + /** @var ImageManager */ |
|
| 50 | + private $imageManager; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * IconController constructor. |
|
| 54 | - * |
|
| 55 | - * @param string $appName |
|
| 56 | - * @param IRequest $request |
|
| 57 | - * @param ThemingDefaults $themingDefaults |
|
| 58 | - * @param Util $util |
|
| 59 | - * @param ITimeFactory $timeFactory |
|
| 60 | - * @param IConfig $config |
|
| 61 | - * @param IconBuilder $iconBuilder |
|
| 62 | - * @param ImageManager $imageManager |
|
| 63 | - */ |
|
| 64 | - public function __construct( |
|
| 65 | - $appName, |
|
| 66 | - IRequest $request, |
|
| 67 | - ThemingDefaults $themingDefaults, |
|
| 68 | - Util $util, |
|
| 69 | - ITimeFactory $timeFactory, |
|
| 70 | - IConfig $config, |
|
| 71 | - IconBuilder $iconBuilder, |
|
| 72 | - ImageManager $imageManager |
|
| 73 | - ) { |
|
| 74 | - parent::__construct($appName, $request); |
|
| 52 | + /** |
|
| 53 | + * IconController constructor. |
|
| 54 | + * |
|
| 55 | + * @param string $appName |
|
| 56 | + * @param IRequest $request |
|
| 57 | + * @param ThemingDefaults $themingDefaults |
|
| 58 | + * @param Util $util |
|
| 59 | + * @param ITimeFactory $timeFactory |
|
| 60 | + * @param IConfig $config |
|
| 61 | + * @param IconBuilder $iconBuilder |
|
| 62 | + * @param ImageManager $imageManager |
|
| 63 | + */ |
|
| 64 | + public function __construct( |
|
| 65 | + $appName, |
|
| 66 | + IRequest $request, |
|
| 67 | + ThemingDefaults $themingDefaults, |
|
| 68 | + Util $util, |
|
| 69 | + ITimeFactory $timeFactory, |
|
| 70 | + IConfig $config, |
|
| 71 | + IconBuilder $iconBuilder, |
|
| 72 | + ImageManager $imageManager |
|
| 73 | + ) { |
|
| 74 | + parent::__construct($appName, $request); |
|
| 75 | 75 | |
| 76 | - $this->themingDefaults = $themingDefaults; |
|
| 77 | - $this->util = $util; |
|
| 78 | - $this->timeFactory = $timeFactory; |
|
| 79 | - $this->config = $config; |
|
| 80 | - $this->iconBuilder = $iconBuilder; |
|
| 81 | - $this->imageManager = $imageManager; |
|
| 82 | - } |
|
| 76 | + $this->themingDefaults = $themingDefaults; |
|
| 77 | + $this->util = $util; |
|
| 78 | + $this->timeFactory = $timeFactory; |
|
| 79 | + $this->config = $config; |
|
| 80 | + $this->iconBuilder = $iconBuilder; |
|
| 81 | + $this->imageManager = $imageManager; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @PublicPage |
|
| 86 | - * @NoCSRFRequired |
|
| 87 | - * |
|
| 88 | - * @param $app string app name |
|
| 89 | - * @param $image string image file name (svg required) |
|
| 90 | - * @return FileDisplayResponse|NotFoundResponse |
|
| 91 | - */ |
|
| 92 | - public function getThemedIcon($app, $image) { |
|
| 93 | - try { |
|
| 94 | - $iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image)); |
|
| 95 | - } catch (NotFoundException $exception) { |
|
| 96 | - $icon = $this->iconBuilder->colorSvg($app, $image); |
|
| 97 | - if ($icon === false || $icon === "") { |
|
| 98 | - return new NotFoundResponse(); |
|
| 99 | - } |
|
| 100 | - $iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon); |
|
| 101 | - } |
|
| 102 | - if ($iconFile !== false) { |
|
| 103 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
|
| 104 | - $response->cacheFor(86400); |
|
| 105 | - $expires = new \DateTime(); |
|
| 106 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 107 | - $expires->add(new \DateInterval('PT24H')); |
|
| 108 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 109 | - $response->addHeader('Pragma', 'cache'); |
|
| 110 | - return $response; |
|
| 111 | - } else { |
|
| 112 | - return new NotFoundResponse(); |
|
| 113 | - } |
|
| 114 | - } |
|
| 84 | + /** |
|
| 85 | + * @PublicPage |
|
| 86 | + * @NoCSRFRequired |
|
| 87 | + * |
|
| 88 | + * @param $app string app name |
|
| 89 | + * @param $image string image file name (svg required) |
|
| 90 | + * @return FileDisplayResponse|NotFoundResponse |
|
| 91 | + */ |
|
| 92 | + public function getThemedIcon($app, $image) { |
|
| 93 | + try { |
|
| 94 | + $iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image)); |
|
| 95 | + } catch (NotFoundException $exception) { |
|
| 96 | + $icon = $this->iconBuilder->colorSvg($app, $image); |
|
| 97 | + if ($icon === false || $icon === "") { |
|
| 98 | + return new NotFoundResponse(); |
|
| 99 | + } |
|
| 100 | + $iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon); |
|
| 101 | + } |
|
| 102 | + if ($iconFile !== false) { |
|
| 103 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
|
| 104 | + $response->cacheFor(86400); |
|
| 105 | + $expires = new \DateTime(); |
|
| 106 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 107 | + $expires->add(new \DateInterval('PT24H')); |
|
| 108 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 109 | + $response->addHeader('Pragma', 'cache'); |
|
| 110 | + return $response; |
|
| 111 | + } else { |
|
| 112 | + return new NotFoundResponse(); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Return a 32x32 favicon as png |
|
| 118 | - * |
|
| 119 | - * @PublicPage |
|
| 120 | - * @NoCSRFRequired |
|
| 121 | - * |
|
| 122 | - * @param $app string app name |
|
| 123 | - * @return FileDisplayResponse|NotFoundResponse |
|
| 124 | - */ |
|
| 125 | - public function getFavicon($app = "core") { |
|
| 126 | - if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 127 | - try { |
|
| 128 | - $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
| 129 | - } catch (NotFoundException $exception) { |
|
| 130 | - $icon = $this->iconBuilder->getFavicon($app); |
|
| 131 | - $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
| 132 | - } |
|
| 133 | - if ($iconFile !== false) { |
|
| 134 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
|
| 135 | - $response->cacheFor(86400); |
|
| 136 | - $expires = new \DateTime(); |
|
| 137 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 138 | - $expires->add(new \DateInterval('PT24H')); |
|
| 139 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 140 | - $response->addHeader('Pragma', 'cache'); |
|
| 141 | - return $response; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - return new NotFoundResponse(); |
|
| 145 | - } |
|
| 116 | + /** |
|
| 117 | + * Return a 32x32 favicon as png |
|
| 118 | + * |
|
| 119 | + * @PublicPage |
|
| 120 | + * @NoCSRFRequired |
|
| 121 | + * |
|
| 122 | + * @param $app string app name |
|
| 123 | + * @return FileDisplayResponse|NotFoundResponse |
|
| 124 | + */ |
|
| 125 | + public function getFavicon($app = "core") { |
|
| 126 | + if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 127 | + try { |
|
| 128 | + $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
| 129 | + } catch (NotFoundException $exception) { |
|
| 130 | + $icon = $this->iconBuilder->getFavicon($app); |
|
| 131 | + $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
| 132 | + } |
|
| 133 | + if ($iconFile !== false) { |
|
| 134 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
|
| 135 | + $response->cacheFor(86400); |
|
| 136 | + $expires = new \DateTime(); |
|
| 137 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 138 | + $expires->add(new \DateInterval('PT24H')); |
|
| 139 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 140 | + $response->addHeader('Pragma', 'cache'); |
|
| 141 | + return $response; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + return new NotFoundResponse(); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Return a 512x512 icon for touch devices |
|
| 149 | - * |
|
| 150 | - * @PublicPage |
|
| 151 | - * @NoCSRFRequired |
|
| 152 | - * |
|
| 153 | - * @param $app string app name |
|
| 154 | - * @return FileDisplayResponse|NotFoundResponse |
|
| 155 | - */ |
|
| 156 | - public function getTouchIcon($app = "core") { |
|
| 157 | - if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 158 | - try { |
|
| 159 | - $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
| 160 | - } catch (NotFoundException $exception) { |
|
| 161 | - $icon = $this->iconBuilder->getTouchIcon($app); |
|
| 162 | - $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
| 163 | - } |
|
| 164 | - if ($iconFile !== false) { |
|
| 165 | - $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
|
| 166 | - $response->cacheFor(86400); |
|
| 167 | - $expires = new \DateTime(); |
|
| 168 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 169 | - $expires->add(new \DateInterval('PT24H')); |
|
| 170 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 171 | - $response->addHeader('Pragma', 'cache'); |
|
| 172 | - return $response; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - return new NotFoundResponse(); |
|
| 176 | - } |
|
| 147 | + /** |
|
| 148 | + * Return a 512x512 icon for touch devices |
|
| 149 | + * |
|
| 150 | + * @PublicPage |
|
| 151 | + * @NoCSRFRequired |
|
| 152 | + * |
|
| 153 | + * @param $app string app name |
|
| 154 | + * @return FileDisplayResponse|NotFoundResponse |
|
| 155 | + */ |
|
| 156 | + public function getTouchIcon($app = "core") { |
|
| 157 | + if ($this->themingDefaults->shouldReplaceIcons()) { |
|
| 158 | + try { |
|
| 159 | + $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
| 160 | + } catch (NotFoundException $exception) { |
|
| 161 | + $icon = $this->iconBuilder->getTouchIcon($app); |
|
| 162 | + $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
| 163 | + } |
|
| 164 | + if ($iconFile !== false) { |
|
| 165 | + $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
|
| 166 | + $response->cacheFor(86400); |
|
| 167 | + $expires = new \DateTime(); |
|
| 168 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 169 | + $expires->add(new \DateInterval('PT24H')); |
|
| 170 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
| 171 | + $response->addHeader('Pragma', 'cache'); |
|
| 172 | + return $response; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + return new NotFoundResponse(); |
|
| 176 | + } |
|
| 177 | 177 | } |
@@ -40,175 +40,175 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | class Defaults { |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * \OC_Defaults instance to retrieve the defaults |
|
| 45 | - * @since 6.0.0 |
|
| 46 | - */ |
|
| 47 | - private $defaults; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * creates a \OC_Defaults instance which is used in all methods to retrieve the |
|
| 51 | - * actual defaults |
|
| 52 | - * @since 6.0.0 |
|
| 53 | - */ |
|
| 54 | - public function __construct(\OC_Defaults $defaults = null) { |
|
| 55 | - if ($defaults === null) { |
|
| 56 | - $defaults = \OC::$server->getThemingDefaults(); |
|
| 57 | - } |
|
| 58 | - $this->defaults = $defaults; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * get base URL for the organisation behind your ownCloud instance |
|
| 63 | - * @return string |
|
| 64 | - * @since 6.0.0 |
|
| 65 | - */ |
|
| 66 | - public function getBaseUrl() { |
|
| 67 | - return $this->defaults->getBaseUrl(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * link to the desktop sync client |
|
| 72 | - * @return string |
|
| 73 | - * @since 6.0.0 |
|
| 74 | - */ |
|
| 75 | - public function getSyncClientUrl() { |
|
| 76 | - return $this->defaults->getSyncClientUrl(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * link to the iOS client |
|
| 81 | - * @return string |
|
| 82 | - * @since 8.0.0 |
|
| 83 | - */ |
|
| 84 | - public function getiOSClientUrl() { |
|
| 85 | - return $this->defaults->getiOSClientUrl(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * link to the Android client |
|
| 90 | - * @return string |
|
| 91 | - * @since 8.0.0 |
|
| 92 | - */ |
|
| 93 | - public function getAndroidClientUrl() { |
|
| 94 | - return $this->defaults->getAndroidClientUrl(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * base URL to the documentation of your ownCloud instance |
|
| 99 | - * @return string |
|
| 100 | - * @since 6.0.0 |
|
| 101 | - */ |
|
| 102 | - public function getDocBaseUrl() { |
|
| 103 | - return $this->defaults->getDocBaseUrl(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * name of your ownCloud instance |
|
| 108 | - * @return string |
|
| 109 | - * @since 6.0.0 |
|
| 110 | - */ |
|
| 111 | - public function getName() { |
|
| 112 | - return $this->defaults->getName(); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * name of your ownCloud instance containing HTML styles |
|
| 117 | - * @return string |
|
| 118 | - * @since 8.0.0 |
|
| 119 | - */ |
|
| 120 | - public function getHTMLName() { |
|
| 121 | - return $this->defaults->getHTMLName(); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Entity behind your onwCloud instance |
|
| 126 | - * @return string |
|
| 127 | - * @since 6.0.0 |
|
| 128 | - */ |
|
| 129 | - public function getEntity() { |
|
| 130 | - return $this->defaults->getEntity(); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * ownCloud slogan |
|
| 135 | - * @return string |
|
| 136 | - * @since 6.0.0 |
|
| 137 | - */ |
|
| 138 | - public function getSlogan() { |
|
| 139 | - return $this->defaults->getSlogan(); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * logo claim |
|
| 144 | - * @return string |
|
| 145 | - * @since 6.0.0 |
|
| 146 | - */ |
|
| 147 | - public function getLogoClaim() { |
|
| 148 | - return $this->defaults->getLogoClaim(); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * footer, short version |
|
| 153 | - * @return string |
|
| 154 | - * @since 6.0.0 |
|
| 155 | - */ |
|
| 156 | - public function getShortFooter() { |
|
| 157 | - return $this->defaults->getShortFooter(); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * footer, long version |
|
| 162 | - * @return string |
|
| 163 | - * @since 6.0.0 |
|
| 164 | - */ |
|
| 165 | - public function getLongFooter() { |
|
| 166 | - return $this->defaults->getLongFooter(); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Returns the AppId for the App Store for the iOS Client |
|
| 171 | - * @return string AppId |
|
| 172 | - * @since 8.0.0 |
|
| 173 | - */ |
|
| 174 | - public function getiTunesAppId() { |
|
| 175 | - return $this->defaults->getiTunesAppId(); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Themed logo url |
|
| 180 | - * |
|
| 181 | - * @return string |
|
| 182 | - * @since 12.0.0 |
|
| 183 | - */ |
|
| 184 | - public function getLogo() { |
|
| 185 | - return $this->defaults->getLogo(); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Returns primary color |
|
| 190 | - * @return string |
|
| 191 | - * @since 12.0.0 |
|
| 192 | - */ |
|
| 193 | - public function getColorPrimary() { |
|
| 194 | - return $this->defaults->getColorPrimary(); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @param string $key |
|
| 199 | - * @return string URL to doc with key |
|
| 200 | - * @since 12.0.0 |
|
| 201 | - */ |
|
| 202 | - public function buildDocLinkToKey($key) { |
|
| 203 | - return $this->defaults->buildDocLinkToKey($key); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Returns the title |
|
| 208 | - * @return string title |
|
| 209 | - * @since 12.0.0 |
|
| 210 | - */ |
|
| 211 | - public function getTitle() { |
|
| 212 | - return $this->defaults->getTitle(); |
|
| 213 | - } |
|
| 43 | + /** |
|
| 44 | + * \OC_Defaults instance to retrieve the defaults |
|
| 45 | + * @since 6.0.0 |
|
| 46 | + */ |
|
| 47 | + private $defaults; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * creates a \OC_Defaults instance which is used in all methods to retrieve the |
|
| 51 | + * actual defaults |
|
| 52 | + * @since 6.0.0 |
|
| 53 | + */ |
|
| 54 | + public function __construct(\OC_Defaults $defaults = null) { |
|
| 55 | + if ($defaults === null) { |
|
| 56 | + $defaults = \OC::$server->getThemingDefaults(); |
|
| 57 | + } |
|
| 58 | + $this->defaults = $defaults; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * get base URL for the organisation behind your ownCloud instance |
|
| 63 | + * @return string |
|
| 64 | + * @since 6.0.0 |
|
| 65 | + */ |
|
| 66 | + public function getBaseUrl() { |
|
| 67 | + return $this->defaults->getBaseUrl(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * link to the desktop sync client |
|
| 72 | + * @return string |
|
| 73 | + * @since 6.0.0 |
|
| 74 | + */ |
|
| 75 | + public function getSyncClientUrl() { |
|
| 76 | + return $this->defaults->getSyncClientUrl(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * link to the iOS client |
|
| 81 | + * @return string |
|
| 82 | + * @since 8.0.0 |
|
| 83 | + */ |
|
| 84 | + public function getiOSClientUrl() { |
|
| 85 | + return $this->defaults->getiOSClientUrl(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * link to the Android client |
|
| 90 | + * @return string |
|
| 91 | + * @since 8.0.0 |
|
| 92 | + */ |
|
| 93 | + public function getAndroidClientUrl() { |
|
| 94 | + return $this->defaults->getAndroidClientUrl(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * base URL to the documentation of your ownCloud instance |
|
| 99 | + * @return string |
|
| 100 | + * @since 6.0.0 |
|
| 101 | + */ |
|
| 102 | + public function getDocBaseUrl() { |
|
| 103 | + return $this->defaults->getDocBaseUrl(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * name of your ownCloud instance |
|
| 108 | + * @return string |
|
| 109 | + * @since 6.0.0 |
|
| 110 | + */ |
|
| 111 | + public function getName() { |
|
| 112 | + return $this->defaults->getName(); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * name of your ownCloud instance containing HTML styles |
|
| 117 | + * @return string |
|
| 118 | + * @since 8.0.0 |
|
| 119 | + */ |
|
| 120 | + public function getHTMLName() { |
|
| 121 | + return $this->defaults->getHTMLName(); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Entity behind your onwCloud instance |
|
| 126 | + * @return string |
|
| 127 | + * @since 6.0.0 |
|
| 128 | + */ |
|
| 129 | + public function getEntity() { |
|
| 130 | + return $this->defaults->getEntity(); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * ownCloud slogan |
|
| 135 | + * @return string |
|
| 136 | + * @since 6.0.0 |
|
| 137 | + */ |
|
| 138 | + public function getSlogan() { |
|
| 139 | + return $this->defaults->getSlogan(); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * logo claim |
|
| 144 | + * @return string |
|
| 145 | + * @since 6.0.0 |
|
| 146 | + */ |
|
| 147 | + public function getLogoClaim() { |
|
| 148 | + return $this->defaults->getLogoClaim(); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * footer, short version |
|
| 153 | + * @return string |
|
| 154 | + * @since 6.0.0 |
|
| 155 | + */ |
|
| 156 | + public function getShortFooter() { |
|
| 157 | + return $this->defaults->getShortFooter(); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * footer, long version |
|
| 162 | + * @return string |
|
| 163 | + * @since 6.0.0 |
|
| 164 | + */ |
|
| 165 | + public function getLongFooter() { |
|
| 166 | + return $this->defaults->getLongFooter(); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Returns the AppId for the App Store for the iOS Client |
|
| 171 | + * @return string AppId |
|
| 172 | + * @since 8.0.0 |
|
| 173 | + */ |
|
| 174 | + public function getiTunesAppId() { |
|
| 175 | + return $this->defaults->getiTunesAppId(); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Themed logo url |
|
| 180 | + * |
|
| 181 | + * @return string |
|
| 182 | + * @since 12.0.0 |
|
| 183 | + */ |
|
| 184 | + public function getLogo() { |
|
| 185 | + return $this->defaults->getLogo(); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Returns primary color |
|
| 190 | + * @return string |
|
| 191 | + * @since 12.0.0 |
|
| 192 | + */ |
|
| 193 | + public function getColorPrimary() { |
|
| 194 | + return $this->defaults->getColorPrimary(); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @param string $key |
|
| 199 | + * @return string URL to doc with key |
|
| 200 | + * @since 12.0.0 |
|
| 201 | + */ |
|
| 202 | + public function buildDocLinkToKey($key) { |
|
| 203 | + return $this->defaults->buildDocLinkToKey($key); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Returns the title |
|
| 208 | + * @return string title |
|
| 209 | + * @since 12.0.0 |
|
| 210 | + */ |
|
| 211 | + public function getTitle() { |
|
| 212 | + return $this->defaults->getTitle(); |
|
| 213 | + } |
|
| 214 | 214 | } |
@@ -46,282 +46,282 @@ discard block |
||
| 46 | 46 | * @package OC\Settings\Controller |
| 47 | 47 | */ |
| 48 | 48 | class CheckSetupController extends Controller { |
| 49 | - /** @var IConfig */ |
|
| 50 | - private $config; |
|
| 51 | - /** @var IClientService */ |
|
| 52 | - private $clientService; |
|
| 53 | - /** @var \OC_Util */ |
|
| 54 | - private $util; |
|
| 55 | - /** @var IURLGenerator */ |
|
| 56 | - private $urlGenerator; |
|
| 57 | - /** @var IL10N */ |
|
| 58 | - private $l10n; |
|
| 59 | - /** @var Checker */ |
|
| 60 | - private $checker; |
|
| 61 | - /** @var ILogger */ |
|
| 62 | - private $logger; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @param string $AppName |
|
| 66 | - * @param IRequest $request |
|
| 67 | - * @param IConfig $config |
|
| 68 | - * @param IClientService $clientService |
|
| 69 | - * @param IURLGenerator $urlGenerator |
|
| 70 | - * @param \OC_Util $util |
|
| 71 | - * @param IL10N $l10n |
|
| 72 | - * @param Checker $checker |
|
| 73 | - * @param ILogger $logger |
|
| 74 | - */ |
|
| 75 | - public function __construct($AppName, |
|
| 76 | - IRequest $request, |
|
| 77 | - IConfig $config, |
|
| 78 | - IClientService $clientService, |
|
| 79 | - IURLGenerator $urlGenerator, |
|
| 80 | - \OC_Util $util, |
|
| 81 | - IL10N $l10n, |
|
| 82 | - Checker $checker, |
|
| 83 | - ILogger $logger) { |
|
| 84 | - parent::__construct($AppName, $request); |
|
| 85 | - $this->config = $config; |
|
| 86 | - $this->clientService = $clientService; |
|
| 87 | - $this->util = $util; |
|
| 88 | - $this->urlGenerator = $urlGenerator; |
|
| 89 | - $this->l10n = $l10n; |
|
| 90 | - $this->checker = $checker; |
|
| 91 | - $this->logger = $logger; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Checks if the ownCloud server can connect to the internet using HTTPS and HTTP |
|
| 96 | - * @return bool |
|
| 97 | - */ |
|
| 98 | - private function isInternetConnectionWorking() { |
|
| 99 | - if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
| 100 | - return false; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $siteArray = ['www.nextcloud.com', |
|
| 104 | - 'www.google.com', |
|
| 105 | - 'www.github.com']; |
|
| 106 | - |
|
| 107 | - foreach($siteArray as $site) { |
|
| 108 | - if ($this->isSiteReachable($site)) { |
|
| 109 | - return true; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - return false; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Chceks if the ownCloud server can connect to a specific URL using both HTTPS and HTTP |
|
| 117 | - * @return bool |
|
| 118 | - */ |
|
| 119 | - private function isSiteReachable($sitename) { |
|
| 120 | - $httpSiteName = 'http://' . $sitename . '/'; |
|
| 121 | - $httpsSiteName = 'https://' . $sitename . '/'; |
|
| 122 | - |
|
| 123 | - try { |
|
| 124 | - $client = $this->clientService->newClient(); |
|
| 125 | - $client->get($httpSiteName); |
|
| 126 | - $client->get($httpsSiteName); |
|
| 127 | - } catch (\Exception $e) { |
|
| 128 | - $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
| 129 | - return false; |
|
| 130 | - } |
|
| 131 | - return true; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Checks whether a local memcache is installed or not |
|
| 136 | - * @return bool |
|
| 137 | - */ |
|
| 138 | - private function isMemcacheConfigured() { |
|
| 139 | - return $this->config->getSystemValue('memcache.local', null) !== null; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Whether /dev/urandom is available to the PHP controller |
|
| 144 | - * |
|
| 145 | - * @return bool |
|
| 146 | - */ |
|
| 147 | - private function isUrandomAvailable() { |
|
| 148 | - if(@file_exists('/dev/urandom')) { |
|
| 149 | - $file = fopen('/dev/urandom', 'rb'); |
|
| 150 | - if($file) { |
|
| 151 | - fclose($file); |
|
| 152 | - return true; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return false; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Public for the sake of unit-testing |
|
| 161 | - * |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - protected function getCurlVersion() { |
|
| 165 | - return curl_version(); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
| 170 | - * have multiple bugs which likely lead to problems in combination with |
|
| 171 | - * functionality required by ownCloud such as SNI. |
|
| 172 | - * |
|
| 173 | - * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
| 174 | - * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - private function isUsedTlsLibOutdated() { |
|
| 178 | - // Don't run check when: |
|
| 179 | - // 1. Server has `has_internet_connection` set to false |
|
| 180 | - // 2. AppStore AND S2S is disabled |
|
| 181 | - if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
| 182 | - return ''; |
|
| 183 | - } |
|
| 184 | - if(!$this->config->getSystemValue('appstoreenabled', true) |
|
| 185 | - && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
| 186 | - && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
| 187 | - return ''; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $versionString = $this->getCurlVersion(); |
|
| 191 | - if(isset($versionString['ssl_version'])) { |
|
| 192 | - $versionString = $versionString['ssl_version']; |
|
| 193 | - } else { |
|
| 194 | - return ''; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
| 198 | - if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
| 199 | - $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
| 203 | - if(strpos($versionString, 'OpenSSL/') === 0) { |
|
| 204 | - $majorVersion = substr($versionString, 8, 5); |
|
| 205 | - $patchRelease = substr($versionString, 13, 6); |
|
| 206 | - |
|
| 207 | - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
| 208 | - ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
| 209 | - 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]); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - // Check if NSS and perform heuristic check |
|
| 214 | - if(strpos($versionString, 'NSS/') === 0) { |
|
| 215 | - try { |
|
| 216 | - $firstClient = $this->clientService->newClient(); |
|
| 217 | - $firstClient->get('https://www.owncloud.org/'); |
|
| 218 | - |
|
| 219 | - $secondClient = $this->clientService->newClient(); |
|
| 220 | - $secondClient->get('https://owncloud.org/'); |
|
| 221 | - } catch (ClientException $e) { |
|
| 222 | - if($e->getResponse()->getStatusCode() === 400) { |
|
| 223 | - 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]); |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return ''; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Whether the version is outdated |
|
| 233 | - * |
|
| 234 | - * @return bool |
|
| 235 | - */ |
|
| 236 | - protected function isPhpOutdated() { |
|
| 237 | - if (version_compare(PHP_VERSION, '5.5.0') === -1) { |
|
| 238 | - return true; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return false; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * Whether the php version is still supported (at time of release) |
|
| 246 | - * according to: https://secure.php.net/supported-versions.php |
|
| 247 | - * |
|
| 248 | - * @return array |
|
| 249 | - */ |
|
| 250 | - private function isPhpSupported() { |
|
| 251 | - return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Check if the reverse proxy configuration is working as expected |
|
| 256 | - * |
|
| 257 | - * @return bool |
|
| 258 | - */ |
|
| 259 | - private function forwardedForHeadersWorking() { |
|
| 260 | - $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); |
|
| 261 | - $remoteAddress = $this->request->getRemoteAddress(); |
|
| 262 | - |
|
| 263 | - if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
| 264 | - return false; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - // either not enabled or working correctly |
|
| 268 | - return true; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Checks if the correct memcache module for PHP is installed. Only |
|
| 273 | - * fails if memcached is configured and the working module is not installed. |
|
| 274 | - * |
|
| 275 | - * @return bool |
|
| 276 | - */ |
|
| 277 | - private function isCorrectMemcachedPHPModuleInstalled() { |
|
| 278 | - if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
| 279 | - return true; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // there are two different memcached modules for PHP |
|
| 283 | - // we only support memcached and not memcache |
|
| 284 | - // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
| 285 | - return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Checks if set_time_limit is not disabled. |
|
| 290 | - * |
|
| 291 | - * @return bool |
|
| 292 | - */ |
|
| 293 | - private function isSettimelimitAvailable() { |
|
| 294 | - if (function_exists('set_time_limit') |
|
| 295 | - && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 296 | - return true; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - return false; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * @return RedirectResponse |
|
| 304 | - */ |
|
| 305 | - public function rescanFailedIntegrityCheck() { |
|
| 306 | - $this->checker->runInstanceVerification(); |
|
| 307 | - return new RedirectResponse( |
|
| 308 | - $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
| 309 | - ); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * @NoCSRFRequired |
|
| 314 | - * @return DataResponse |
|
| 315 | - */ |
|
| 316 | - public function getFailedIntegrityCheckFiles() { |
|
| 317 | - if(!$this->checker->isCodeCheckEnforced()) { |
|
| 318 | - return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - $completeResults = $this->checker->getResults(); |
|
| 322 | - |
|
| 323 | - if(!empty($completeResults)) { |
|
| 324 | - $formattedTextResponse = 'Technical information |
|
| 49 | + /** @var IConfig */ |
|
| 50 | + private $config; |
|
| 51 | + /** @var IClientService */ |
|
| 52 | + private $clientService; |
|
| 53 | + /** @var \OC_Util */ |
|
| 54 | + private $util; |
|
| 55 | + /** @var IURLGenerator */ |
|
| 56 | + private $urlGenerator; |
|
| 57 | + /** @var IL10N */ |
|
| 58 | + private $l10n; |
|
| 59 | + /** @var Checker */ |
|
| 60 | + private $checker; |
|
| 61 | + /** @var ILogger */ |
|
| 62 | + private $logger; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @param string $AppName |
|
| 66 | + * @param IRequest $request |
|
| 67 | + * @param IConfig $config |
|
| 68 | + * @param IClientService $clientService |
|
| 69 | + * @param IURLGenerator $urlGenerator |
|
| 70 | + * @param \OC_Util $util |
|
| 71 | + * @param IL10N $l10n |
|
| 72 | + * @param Checker $checker |
|
| 73 | + * @param ILogger $logger |
|
| 74 | + */ |
|
| 75 | + public function __construct($AppName, |
|
| 76 | + IRequest $request, |
|
| 77 | + IConfig $config, |
|
| 78 | + IClientService $clientService, |
|
| 79 | + IURLGenerator $urlGenerator, |
|
| 80 | + \OC_Util $util, |
|
| 81 | + IL10N $l10n, |
|
| 82 | + Checker $checker, |
|
| 83 | + ILogger $logger) { |
|
| 84 | + parent::__construct($AppName, $request); |
|
| 85 | + $this->config = $config; |
|
| 86 | + $this->clientService = $clientService; |
|
| 87 | + $this->util = $util; |
|
| 88 | + $this->urlGenerator = $urlGenerator; |
|
| 89 | + $this->l10n = $l10n; |
|
| 90 | + $this->checker = $checker; |
|
| 91 | + $this->logger = $logger; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Checks if the ownCloud server can connect to the internet using HTTPS and HTTP |
|
| 96 | + * @return bool |
|
| 97 | + */ |
|
| 98 | + private function isInternetConnectionWorking() { |
|
| 99 | + if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
| 100 | + return false; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $siteArray = ['www.nextcloud.com', |
|
| 104 | + 'www.google.com', |
|
| 105 | + 'www.github.com']; |
|
| 106 | + |
|
| 107 | + foreach($siteArray as $site) { |
|
| 108 | + if ($this->isSiteReachable($site)) { |
|
| 109 | + return true; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Chceks if the ownCloud server can connect to a specific URL using both HTTPS and HTTP |
|
| 117 | + * @return bool |
|
| 118 | + */ |
|
| 119 | + private function isSiteReachable($sitename) { |
|
| 120 | + $httpSiteName = 'http://' . $sitename . '/'; |
|
| 121 | + $httpsSiteName = 'https://' . $sitename . '/'; |
|
| 122 | + |
|
| 123 | + try { |
|
| 124 | + $client = $this->clientService->newClient(); |
|
| 125 | + $client->get($httpSiteName); |
|
| 126 | + $client->get($httpsSiteName); |
|
| 127 | + } catch (\Exception $e) { |
|
| 128 | + $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
| 129 | + return false; |
|
| 130 | + } |
|
| 131 | + return true; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Checks whether a local memcache is installed or not |
|
| 136 | + * @return bool |
|
| 137 | + */ |
|
| 138 | + private function isMemcacheConfigured() { |
|
| 139 | + return $this->config->getSystemValue('memcache.local', null) !== null; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Whether /dev/urandom is available to the PHP controller |
|
| 144 | + * |
|
| 145 | + * @return bool |
|
| 146 | + */ |
|
| 147 | + private function isUrandomAvailable() { |
|
| 148 | + if(@file_exists('/dev/urandom')) { |
|
| 149 | + $file = fopen('/dev/urandom', 'rb'); |
|
| 150 | + if($file) { |
|
| 151 | + fclose($file); |
|
| 152 | + return true; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return false; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Public for the sake of unit-testing |
|
| 161 | + * |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + protected function getCurlVersion() { |
|
| 165 | + return curl_version(); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
| 170 | + * have multiple bugs which likely lead to problems in combination with |
|
| 171 | + * functionality required by ownCloud such as SNI. |
|
| 172 | + * |
|
| 173 | + * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
| 174 | + * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
| 175 | + * @return string |
|
| 176 | + */ |
|
| 177 | + private function isUsedTlsLibOutdated() { |
|
| 178 | + // Don't run check when: |
|
| 179 | + // 1. Server has `has_internet_connection` set to false |
|
| 180 | + // 2. AppStore AND S2S is disabled |
|
| 181 | + if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
| 182 | + return ''; |
|
| 183 | + } |
|
| 184 | + if(!$this->config->getSystemValue('appstoreenabled', true) |
|
| 185 | + && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
| 186 | + && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
| 187 | + return ''; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $versionString = $this->getCurlVersion(); |
|
| 191 | + if(isset($versionString['ssl_version'])) { |
|
| 192 | + $versionString = $versionString['ssl_version']; |
|
| 193 | + } else { |
|
| 194 | + return ''; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
| 198 | + if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
| 199 | + $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
| 203 | + if(strpos($versionString, 'OpenSSL/') === 0) { |
|
| 204 | + $majorVersion = substr($versionString, 8, 5); |
|
| 205 | + $patchRelease = substr($versionString, 13, 6); |
|
| 206 | + |
|
| 207 | + if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
| 208 | + ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
| 209 | + 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]); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + // Check if NSS and perform heuristic check |
|
| 214 | + if(strpos($versionString, 'NSS/') === 0) { |
|
| 215 | + try { |
|
| 216 | + $firstClient = $this->clientService->newClient(); |
|
| 217 | + $firstClient->get('https://www.owncloud.org/'); |
|
| 218 | + |
|
| 219 | + $secondClient = $this->clientService->newClient(); |
|
| 220 | + $secondClient->get('https://owncloud.org/'); |
|
| 221 | + } catch (ClientException $e) { |
|
| 222 | + if($e->getResponse()->getStatusCode() === 400) { |
|
| 223 | + 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]); |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return ''; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Whether the version is outdated |
|
| 233 | + * |
|
| 234 | + * @return bool |
|
| 235 | + */ |
|
| 236 | + protected function isPhpOutdated() { |
|
| 237 | + if (version_compare(PHP_VERSION, '5.5.0') === -1) { |
|
| 238 | + return true; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return false; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * Whether the php version is still supported (at time of release) |
|
| 246 | + * according to: https://secure.php.net/supported-versions.php |
|
| 247 | + * |
|
| 248 | + * @return array |
|
| 249 | + */ |
|
| 250 | + private function isPhpSupported() { |
|
| 251 | + return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Check if the reverse proxy configuration is working as expected |
|
| 256 | + * |
|
| 257 | + * @return bool |
|
| 258 | + */ |
|
| 259 | + private function forwardedForHeadersWorking() { |
|
| 260 | + $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); |
|
| 261 | + $remoteAddress = $this->request->getRemoteAddress(); |
|
| 262 | + |
|
| 263 | + if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
| 264 | + return false; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + // either not enabled or working correctly |
|
| 268 | + return true; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Checks if the correct memcache module for PHP is installed. Only |
|
| 273 | + * fails if memcached is configured and the working module is not installed. |
|
| 274 | + * |
|
| 275 | + * @return bool |
|
| 276 | + */ |
|
| 277 | + private function isCorrectMemcachedPHPModuleInstalled() { |
|
| 278 | + if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
| 279 | + return true; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // there are two different memcached modules for PHP |
|
| 283 | + // we only support memcached and not memcache |
|
| 284 | + // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
| 285 | + return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Checks if set_time_limit is not disabled. |
|
| 290 | + * |
|
| 291 | + * @return bool |
|
| 292 | + */ |
|
| 293 | + private function isSettimelimitAvailable() { |
|
| 294 | + if (function_exists('set_time_limit') |
|
| 295 | + && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 296 | + return true; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + return false; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * @return RedirectResponse |
|
| 304 | + */ |
|
| 305 | + public function rescanFailedIntegrityCheck() { |
|
| 306 | + $this->checker->runInstanceVerification(); |
|
| 307 | + return new RedirectResponse( |
|
| 308 | + $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
| 309 | + ); |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * @NoCSRFRequired |
|
| 314 | + * @return DataResponse |
|
| 315 | + */ |
|
| 316 | + public function getFailedIntegrityCheckFiles() { |
|
| 317 | + if(!$this->checker->isCodeCheckEnforced()) { |
|
| 318 | + return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + $completeResults = $this->checker->getResults(); |
|
| 322 | + |
|
| 323 | + if(!empty($completeResults)) { |
|
| 324 | + $formattedTextResponse = 'Technical information |
|
| 325 | 325 | ===================== |
| 326 | 326 | The following list covers which files have failed the integrity check. Please read |
| 327 | 327 | the previous linked documentation to learn more about the errors and how to fix |
@@ -330,103 +330,103 @@ discard block |
||
| 330 | 330 | Results |
| 331 | 331 | ======= |
| 332 | 332 | '; |
| 333 | - foreach($completeResults as $context => $contextResult) { |
|
| 334 | - $formattedTextResponse .= "- $context\n"; |
|
| 335 | - |
|
| 336 | - foreach($contextResult as $category => $result) { |
|
| 337 | - $formattedTextResponse .= "\t- $category\n"; |
|
| 338 | - if($category !== 'EXCEPTION') { |
|
| 339 | - foreach ($result as $key => $results) { |
|
| 340 | - $formattedTextResponse .= "\t\t- $key\n"; |
|
| 341 | - } |
|
| 342 | - } else { |
|
| 343 | - foreach ($result as $key => $results) { |
|
| 344 | - $formattedTextResponse .= "\t\t- $results\n"; |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - $formattedTextResponse .= ' |
|
| 333 | + foreach($completeResults as $context => $contextResult) { |
|
| 334 | + $formattedTextResponse .= "- $context\n"; |
|
| 335 | + |
|
| 336 | + foreach($contextResult as $category => $result) { |
|
| 337 | + $formattedTextResponse .= "\t- $category\n"; |
|
| 338 | + if($category !== 'EXCEPTION') { |
|
| 339 | + foreach ($result as $key => $results) { |
|
| 340 | + $formattedTextResponse .= "\t\t- $key\n"; |
|
| 341 | + } |
|
| 342 | + } else { |
|
| 343 | + foreach ($result as $key => $results) { |
|
| 344 | + $formattedTextResponse .= "\t\t- $results\n"; |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + $formattedTextResponse .= ' |
|
| 352 | 352 | Raw output |
| 353 | 353 | ========== |
| 354 | 354 | '; |
| 355 | - $formattedTextResponse .= print_r($completeResults, true); |
|
| 356 | - } else { |
|
| 357 | - $formattedTextResponse = 'No errors have been found.'; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - $response = new DataDisplayResponse( |
|
| 362 | - $formattedTextResponse, |
|
| 363 | - Http::STATUS_OK, |
|
| 364 | - [ |
|
| 365 | - 'Content-Type' => 'text/plain', |
|
| 366 | - ] |
|
| 367 | - ); |
|
| 368 | - |
|
| 369 | - return $response; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Checks whether a PHP opcache is properly set up |
|
| 374 | - * @return bool |
|
| 375 | - */ |
|
| 376 | - protected function isOpcacheProperlySetup() { |
|
| 377 | - $iniWrapper = new IniGetWrapper(); |
|
| 378 | - |
|
| 379 | - $isOpcacheProperlySetUp = true; |
|
| 380 | - |
|
| 381 | - if(!$iniWrapper->getBool('opcache.enable')) { |
|
| 382 | - $isOpcacheProperlySetUp = false; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
| 386 | - $isOpcacheProperlySetUp = false; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
| 390 | - $isOpcacheProperlySetUp = false; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
| 394 | - $isOpcacheProperlySetUp = false; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
| 398 | - $isOpcacheProperlySetUp = false; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
| 402 | - $isOpcacheProperlySetUp = false; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - return $isOpcacheProperlySetUp; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * @return DataResponse |
|
| 410 | - */ |
|
| 411 | - public function check() { |
|
| 412 | - return new DataResponse( |
|
| 413 | - [ |
|
| 414 | - 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
| 415 | - 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
| 416 | - 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
| 417 | - 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
| 418 | - 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
| 419 | - 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
| 420 | - 'phpSupported' => $this->isPhpSupported(), |
|
| 421 | - 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
| 422 | - 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
| 423 | - 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
| 424 | - 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
| 425 | - 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
| 426 | - 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
| 427 | - 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
| 428 | - 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
| 429 | - ] |
|
| 430 | - ); |
|
| 431 | - } |
|
| 355 | + $formattedTextResponse .= print_r($completeResults, true); |
|
| 356 | + } else { |
|
| 357 | + $formattedTextResponse = 'No errors have been found.'; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + $response = new DataDisplayResponse( |
|
| 362 | + $formattedTextResponse, |
|
| 363 | + Http::STATUS_OK, |
|
| 364 | + [ |
|
| 365 | + 'Content-Type' => 'text/plain', |
|
| 366 | + ] |
|
| 367 | + ); |
|
| 368 | + |
|
| 369 | + return $response; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Checks whether a PHP opcache is properly set up |
|
| 374 | + * @return bool |
|
| 375 | + */ |
|
| 376 | + protected function isOpcacheProperlySetup() { |
|
| 377 | + $iniWrapper = new IniGetWrapper(); |
|
| 378 | + |
|
| 379 | + $isOpcacheProperlySetUp = true; |
|
| 380 | + |
|
| 381 | + if(!$iniWrapper->getBool('opcache.enable')) { |
|
| 382 | + $isOpcacheProperlySetUp = false; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
| 386 | + $isOpcacheProperlySetUp = false; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
| 390 | + $isOpcacheProperlySetUp = false; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
| 394 | + $isOpcacheProperlySetUp = false; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
| 398 | + $isOpcacheProperlySetUp = false; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
| 402 | + $isOpcacheProperlySetUp = false; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + return $isOpcacheProperlySetUp; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * @return DataResponse |
|
| 410 | + */ |
|
| 411 | + public function check() { |
|
| 412 | + return new DataResponse( |
|
| 413 | + [ |
|
| 414 | + 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
| 415 | + 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
| 416 | + 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
| 417 | + 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
| 418 | + 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
| 419 | + 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
| 420 | + 'phpSupported' => $this->isPhpSupported(), |
|
| 421 | + 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
| 422 | + 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
| 423 | + 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
| 424 | + 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
| 425 | + 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
| 426 | + 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
| 427 | + 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
| 428 | + 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
| 429 | + ] |
|
| 430 | + ); |
|
| 431 | + } |
|
| 432 | 432 | } |