httpResponse($toplists); } break; case validateRoute('GET', 'torrents/download/\\d+'): $torrent = new Torrent($db, $user); $torrent->download((int) $params[2]); break; case validateRoute('POST', 'torrents/upload'): $log = new Logs($db); $movieData = new MovieData($db); $sweTv = new SweTv($db); $mailbox = new Mailbox($db, $user); $requests = new Requests($db, $user); $adminlogs = new AdminLogs($db, $user); $torrent = new Torrent($db, $user, $log, $movieData, $sweTv, $requests, $mailbox, null, $adminlogs); $torrentId = $torrent->upload($_FILES["file"], $_POST); httpResponse($torrentId); break; case validateRoute('GET', 'requests'): $requests = new Requests($db, $user); list($requests, $total) = $requests->query((int) $_GET["index"], (int) $_GET["limit"], $_GET["sort"], $_GET["order"], $_GET["searchParams"]); httpResponse($requests, $total); break; case validateRoute('GET', 'requests/\\d+'): $requests = new Requests($db, $user); $movieData = new MovieData($db); $requestResponse = $requests->get($params[1]); $requestVotes = $requests->getVotes($params[1]); $movieDataResponse = $movieData->getData($requestResponse["imdbid"]); httpResponse(array("request" => $requestResponse, "votes" => $requestVotes, "movieData" => $movieDataResponse)); break;
public function actionUpload() { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); $this->setLayoutVar('pageHead', 'Upload a Torrent'); $this->setLayoutVar('pageTitle', 'Upload a Torrent'); $categories = Category::find_all(); $this->setVar('categories', $categories); $this->setVar('title', ''); $this->setVar('description', ''); $this->setVar('category_cid', ''); if (!empty($this->post['submit'])) { if (!($this->post['torrent']['error'] > 0)) { $result = Torrent::upload($this->post['title'], $this->post['description'], $this->post['category_cid'], $this->post['torrent'], $active_user); if ($result['status']) { Flash::set('success', $result['message']); $this->redirect('/torrent/' . $result['id']); die; } else { Flash::set('failure', $result['message']); } } else { Flash::set('failure', 'No .torrent file was specified!'); } $this->setVar('title', $this->post['title']); $this->setVar('description', $this->post['description']); $this->setVar('category_cid', $this->post['category_cid']); } }