. * */ namespace OCA\Passman\Settings; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use OCP\App; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IL10N; use OCP\Settings\ISettings; class Admin implements ISettings { protected IConfig $config; private IL10N $l; /** * Admin constructor. * @param IConfig $config * @param IL10N $l */ public function __construct(IConfig $config, IL10N $l) { $this->config = $config; $this->l = $l; } /** * @return TemplateResponse */ public function getForm(): TemplateResponse { $checkVersion = $this->config->getAppValue('passman', 'check_version', '1') === '1'; $AppInstance = new App(); $localVersion = $AppInstance->getAppInfo("passman")["version"]; $githubVersion = $this->l->t('Unable to get version info'); if ($checkVersion) { // get latest master version $version = false; $url = 'https://raw.githubusercontent.com/nextcloud/passman/master/appinfo/info.xml'; try { $httpClient = new Client(); $response = $httpClient->request('get', $url); $xml = $response->getBody()->getContents(); } catch (GuzzleException $e) { $xml = false; } if ($xml) { $data = @simplexml_load_string($xml); // libxml_disable_entity_loader is deprecated with php8, the vulnerability is disabled by default by libxml with php8 if (\PHP_VERSION_ID < 80000) { $loadEntities = libxml_disable_entity_loader(true); $data = @simplexml_load_string($xml); libxml_disable_entity_loader($loadEntities); } if ($data !== false) { $version = (string)$data->version; } else { libxml_clear_errors(); } } if ($version !== false) { $githubVersion = $version; } } // $ciphers = openssl_get_cipher_methods(); return new TemplateResponse('passman', 'admin', [ 'localVersion' => $localVersion, 'githubVersion' => $githubVersion, 'checkVersion' => $checkVersion, ], 'blank'); } /** * @return string */ public function getSection(): string { return 'additional'; } /** * @return int */ public function getPriority(): int { return 100; } }