nextcloud /
passman
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Nextcloud - passman |
||
| 4 | * |
||
| 5 | * @copyright Copyright (c) 2016, Sander Brand ([email protected]) |
||
| 6 | * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected]) |
||
| 7 | * @license GNU AGPL version 3 or any later version |
||
| 8 | * |
||
| 9 | * This program is free software: you can redistribute it and/or modify |
||
| 10 | * it under the terms of the GNU Affero General Public License as |
||
| 11 | * published by the Free Software Foundation, either version 3 of the |
||
| 12 | * License, or (at your option) any later version. |
||
| 13 | * |
||
| 14 | * This program is distributed in the hope that it will be useful, |
||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 17 | * GNU Affero General Public License for more details. |
||
| 18 | * |
||
| 19 | * You should have received a copy of the GNU Affero General Public License |
||
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 21 | * |
||
| 22 | */ |
||
| 23 | |||
| 24 | namespace OCA\Passman\Settings; |
||
| 25 | |||
| 26 | use GuzzleHttp\Client; |
||
| 27 | use GuzzleHttp\Exception\GuzzleException; |
||
| 28 | use OCP\App\IAppManager; |
||
| 29 | use OCP\AppFramework\Http\TemplateResponse; |
||
| 30 | use OCP\IConfig; |
||
| 31 | use OCP\IL10N; |
||
| 32 | use OCP\Settings\ISettings; |
||
| 33 | |||
| 34 | class Admin implements ISettings { |
||
| 35 | |||
| 36 | protected IConfig $config; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 37 | private IL10N $l; |
||
| 38 | private IAppManager $appManager; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Admin constructor. |
||
| 42 | * @param IConfig $config |
||
| 43 | * @param IL10N $l |
||
| 44 | * @param IAppManager $appManager |
||
| 45 | */ |
||
| 46 | public function __construct(IConfig $config, IL10N $l, IAppManager $appManager) { |
||
| 47 | $this->config = $config; |
||
| 48 | $this->l = $l; |
||
| 49 | $this->appManager = $appManager; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return TemplateResponse |
||
| 54 | */ |
||
| 55 | public function getForm(): TemplateResponse { |
||
| 56 | $checkVersion = $this->config->getAppValue('passman', 'check_version', '1') === '1'; |
||
| 57 | $localVersion = $this->appManager->getAppInfo('passman')["version"]; |
||
| 58 | $githubVersion = $this->l->t('Unable to get version info'); |
||
| 59 | if ($checkVersion) { |
||
| 60 | // get latest master version |
||
| 61 | $version = false; |
||
| 62 | |||
| 63 | $url = 'https://raw.githubusercontent.com/nextcloud/passman/dist/appinfo/info.xml'; |
||
| 64 | try { |
||
| 65 | $httpClient = new Client(); |
||
| 66 | $response = $httpClient->request('get', $url); |
||
| 67 | $xml = $response->getBody()->getContents(); |
||
| 68 | } catch (GuzzleException $e) { |
||
| 69 | $xml = false; |
||
| 70 | } |
||
| 71 | |||
| 72 | if ($xml) { |
||
| 73 | $data = simplexml_load_string($xml); |
||
| 74 | |||
| 75 | // libxml_disable_entity_loader is deprecated with php8, the vulnerability is disabled by default by libxml with php8 |
||
| 76 | if (\PHP_VERSION_ID < 80000) { |
||
| 77 | $loadEntities = libxml_disable_entity_loader(true); |
||
| 78 | $data = simplexml_load_string($xml); |
||
| 79 | libxml_disable_entity_loader($loadEntities); |
||
| 80 | } |
||
| 81 | |||
| 82 | if ($data !== false) { |
||
| 83 | $version = (string)$data->version; |
||
| 84 | } else { |
||
| 85 | libxml_clear_errors(); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($version !== false) { |
||
| 90 | $githubVersion = $version; |
||
| 91 | } |
||
| 92 | } |
||
| 93 | // $ciphers = openssl_get_cipher_methods(); |
||
| 94 | |||
| 95 | return new TemplateResponse('passman', 'admin', [ |
||
| 96 | 'localVersion' => $localVersion, |
||
| 97 | 'githubVersion' => $githubVersion, |
||
| 98 | 'checkVersion' => $checkVersion, |
||
| 99 | ], 'blank'); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | public function getSection(): string { |
||
| 106 | return 'additional'; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @return int |
||
| 111 | */ |
||
| 112 | public function getPriority(): int { |
||
| 113 | return 100; |
||
| 114 | } |
||
| 115 | } |
||
| 116 |