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 = $torrents->getTorrents(approved: true, userInfo: $userInfo, take: 3); $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, ]); } #[Route('GET', '/profile/:name/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, ]); } #[Route('GET', '/profile.php')] public function getProfilePHP($response, $request): void { $response->redirect(sprintf('/profile/%s', (string)$request->getParam('name')), true); } #[Route('GET', '/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); } }