You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Platform.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Julius Härtl <jus@bitgrid.net>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\App;
  27. use OCP\IConfig;
  28. /**
  29. * Class Platform
  30. *
  31. * This class basically abstracts any kind of information which can be retrieved from the underlying system.
  32. *
  33. * @package OC\App
  34. */
  35. class Platform {
  36. /**
  37. * @param IConfig $config
  38. */
  39. public function __construct(IConfig $config) {
  40. $this->config = $config;
  41. }
  42. /**
  43. * @return string
  44. */
  45. public function getPhpVersion() {
  46. return phpversion();
  47. }
  48. /**
  49. * @return int
  50. */
  51. public function getIntSize() {
  52. return PHP_INT_SIZE;
  53. }
  54. /**
  55. * @return string
  56. */
  57. public function getOcVersion() {
  58. $v = \OCP\Util::getVersion();
  59. return implode('.', $v);
  60. }
  61. /**
  62. * @return string
  63. */
  64. public function getDatabase() {
  65. $dbType = $this->config->getSystemValue('dbtype', 'sqlite');
  66. if ($dbType === 'sqlite3') {
  67. $dbType = 'sqlite';
  68. }
  69. return $dbType;
  70. }
  71. /**
  72. * @return string
  73. */
  74. public function getOS() {
  75. return php_uname('s');
  76. }
  77. /**
  78. * @param $command
  79. * @return bool
  80. */
  81. public function isCommandKnown($command) {
  82. $path = \OC_Helper::findBinaryPath($command);
  83. return ($path !== null);
  84. }
  85. public function getLibraryVersion($name) {
  86. $repo = new PlatformRepository();
  87. return $repo->findLibrary($name);
  88. }
  89. public function getArchitecture(): string {
  90. return php_uname('m');
  91. }
  92. }