authInfo->isLoggedIn()) return 403; $users = $this->usersCtx->getUsers(); $torrents = $this->torrentsCtx->getTorrents(); $peers = $this->torrentsCtx->getPeers(); try { $userInfo = $users->getUser($name, 'name'); } catch(RuntimeException $ex) { return 404; } $submissions = []; $torrentInfos = $torrents->getTorrents(approved: true, userInfo: $userInfo, take: 3); foreach($torrentInfos as $torrentInfo) { $submissions[] = [ 'info' => $torrentInfo, 'complete_peers' => $peers->countCompletePeers($torrentInfo), 'incomplete_peers' => $peers->countIncompletePeers($torrentInfo), ]; } $uploading = $peers->countUserUploading($userInfo); $downloading = $peers->countUserDownloading($userInfo); return $this->templating->render('profile', [ 'profile_user' => $userInfo, 'profile_submissions' => $submissions, 'profile_uploading' => $uploading, 'profile_downloading' => $downloading, ]); } #[HttpGet('/profile/([a-zA-Z0-9\-_]+)/history')] public function getHistory($response, $request, string $name) { if(!$this->authInfo->isLoggedIn()) return 403; $users = $this->usersCtx->getUsers(); try { $userInfo = $users->getUser($name, 'name'); } catch(RuntimeException $ex) { return 404; } return $this->templating->render('history', [ 'history_user_info' => $userInfo, ]); } #[HttpGet('/profile.php')] public function getProfilePHP($response, $request): void { $response->redirect(sprintf('/profile/%s', (string)$request->getParam('name')), true); } #[HttpGet('/history.php')] public function getHistoryPHP($response, $request) { $userName = (string)$request->getParam('name'); if($userName === '' && $this->authInfo->isLoggedIn()) $userName = $this->authInfo->getUserName(); if($userName === '') return 404; $url = sprintf('/profile/%s/history', $userName); $filter = (string)$request->getParam('filter'); if($filter !== '') $url .= '?filter=' . $filter; $response->redirect($url, true); } }