public function actionSend($name = null) { if (defined('DISABLE_MESSAGING') && DISABLE_MESSAGING) { throw new Lvc_Exception('Messaging disabled', 404); } $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); if (is_null($name)) { throw new Lvc_Exception('Null username on send action'); } if ($user = User::find(array('name' => $name))) { if (!empty($this->post['submit'])) { $subject = $this->post['subject']; $body = $this->post['body']; $result = Message::send($user, $subject, $body, $active_user); if ($result['status']) { Flash::set('success', $result['message']); $this->redirect('/message/inbox'); die; } else { Flash::set('failure', $result['message']); } $this->setVar('subject', $subject); $this->setVar('body', $body); } $this->setVar('to_user', $user); } else { throw new Lvc_Exception('User Not Found: ' . $name); } }
public function actionIndex() { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); $this->setLayoutVar('pageTitle', 'Requests'); $this->setLayoutVar('pageHead', 'Requests'); }
public function actionIndex() { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); $this->setLayoutVar('pageTitle', 'Charts'); $this->setLayoutVar('pageHead', 'Charts'); $most_snatched = Chart::most_snatched(array('limit' => 10)); $top_uploaders = Chart::top_uploaders(array('limit' => 10, 'user' => $active_user)); $this->setVar('most_snatched', $most_snatched); $this->setVar('top_uploaders', $top_uploaders); }
public function actionNewest($window = 1) { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); if (empty($window)) { $window = 1; } $posts = NewsPost::get_posts(1, $window); $this->setVar('posts', $posts['posts']); $this->setVar('count', $posts['count']); }
public function actionView($errorNum = '404') { $user = User::require_active_user(); //if ($user = get_active_user()) //{ $this->setLayoutVar('active_user', $user); $this->setVar('active_user', $user); //} //else $this->setLayout('outside'); if (strpos($errorNum, '../') !== false) { $errorNum = '404'; } if (isset(self::$errorString[$errorNum])) { $errorMsg = self::$errorString[$errorNum]; header('HTTP/1.1 ' . $errorNum . ' ' . $errorMsg); } else { $errorMsg = 'Not Found'; } $this->setLayoutVar('pageTitle', $errorMsg); $this->setLayoutVar('pageHead', $errorMsg); $this->loadView($this->getControllerName() . '/' . $errorNum); }
public function actionView($pageName = 'home') { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); if (strpos($pageName, '../') !== false) { throw new Lvc_Exception('File Not Found: ' . $sourceFile); } switch ($pageName) { case 'home': $torrents = Torrent::browse(array('category_cid' => -1, 'window' => 5, 'page' => 1)); $news = $this->requestAction('newest', array(), 'news'); //$currently_seeding = User::currently_seeding($active_user); $this->setVar('torrents', $torrents['torrents']); $this->setVar('latest_news', $news); $this->setVar('total_torrents', $torrents['count']); $this->setVar('currently_seeding', $currently_seeding['users']); $this->setVar('currently_seeding_count', $currently_seeding['count']); break; case 'help': $this->setLayoutVar('pageTitle', 'Help'); $this->setLayoutVar('pageHead', 'Help'); break; case 'help/transmission': $this->setLayoutVar('pageTitle', 'Transmission Upload Guide'); $this->setLayoutVar('pageHead', 'Transmission Upload Guide'); break; case 'help/utorrent': $this->setLayoutVar('pageTitle', 'uTorrent Upload Guide'); $this->setLayoutVar('pageHead', 'uTorrent Upload Guide'); break; case 'faq': $this->setLayoutVar('pageTitle', 'FAQ'); $this->setLayoutVar('pageHead', 'Frequently Asked Questions'); break; } $this->loadView('page/' . rtrim($pageName, '/')); }
public function actionActive($name = null, $page = 1) { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); $is_active_user = $name == $active_user->name; if (is_null($page)) { $page = 1; } if ($user = User::find(array('name' => $name))) { //$is_active_user = ($user->name == $active_user->name); if (!$user->shown && !($is_active_user || $active_user->admin)) { throw new Lvc_Exception('Warning: User "' . $active_user->name . '" tried to view hidden user "' . $name . '"'); } $results = $user->torrents_active(array('page' => $page, 'window' => 15)); if (count($results['torrents']) < 1) { throw new Lvc_Exception('No torrents returned'); } $this->setVar('torrents', $results['torrents']); $this->setVar('count', $results['count']); $this->setVar('page', $page); $this->setVar('user', $user); $this->setVar('base_url', WWW_BASE_PATH . 'user/' . $user->name . '/active'); if ($is_active_user) { $this->setLayoutVar('pageHead', 'Your Active Torrents (' . $results['count'] . ')'); $this->setLayoutVar('pageTitle', 'Your Active Torrents'); } else { $this->setLayoutVar('pageHead', $user->name . '\'s Active Torrents (' . $results['count'] . ')'); $this->setLayoutVar('pageTitle', $user->name . '\'s Active Torrents'); } } else { throw new Lvc_Exception('User Not Found: ' . $name); } $this->loadView($this->controllerName . '/torrents'); }
public function actionEdit($fid = null) { $active_user = User::require_active_user(); $this->setLayoutVar('active_user', $active_user); $this->setVar('active_user', $active_user); //Edit — <?php echo $torrent->title; if (is_null($fid)) { throw new Lvc_Exception('Null fid on edit action'); } if ($torrent = Torrent::find(array('fid' => $fid))) { if ($torrent->has_access(array('user' => $active_user))) { if (!empty($this->post['submit'])) { $result = Torrent::edit($fid, $this->post['title'], $this->post['description'], $this->post['category_cid'], $active_user); if ($result['status']) { Flash::set('success', $result['message']); $this->redirect('/torrent/' . $fid); die; } else { $this->setVar('fail_message', $result['message']); } } $categories = Category::find_all(); $this->setVar('categories', $categories); $this->setVar('torrent', $torrent); $this->setLayoutVar('pageHead', 'Edit — ' . $torrent->title); $this->setLayoutVar('pageTitle', 'Edit - ' . $torrent->title); } else { throw new Lvc_Exception('Unauthorized user: '******' tried to edit torrent: ' . $torrent->fid); } } else { throw new Lvc_Exception('Torrent Not Found: ' . $fid); } }