Esempio n. 1
0
 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, '/'));
 }
Esempio n. 2
0
 public function actionBrowse($category_slug = null, $page = 1, $query = '')
 {
     $active_user = User::require_active_user();
     $this->setLayoutVar('active_user', $active_user);
     $this->setVar('active_user', $active_user);
     $this->setLayoutVar('tab', 'browse');
     $this->passQueryString();
     $query = urldecode($query);
     $sort_col = isset($this->get['sort']) ? $this->get['sort'] : 'added';
     $sort_order = isset($this->get['order']) ? $this->get['order'] : 'desc';
     $this->setVar('sort', $sort_col);
     $this->setVar('order', $sort_order);
     switch ($sort_col) {
         case 'added':
             $sort_col = 'ctime';
             break;
         case 'leechers':
         case 'seeders':
         case 'size':
             //case 'title': // removing title until I get sphinx set up correctly
             // Keep these as they are
             break;
         case 'snatches':
             $sort_col = 'completed';
             break;
         default:
             // default to ctime
             $sort_col = 'ctime';
             break;
     }
     // default to desc
     if ($sort_order != 'desc' && $sort_order != 'asc') {
         $sort_order = 'desc';
     }
     if (is_null($page)) {
         $page = 1;
     }
     if (!empty($category_slug) && $category_slug != 'all') {
         if ($category = Category::find(array('slug' => $category_slug))) {
         } else {
             throw new Lvc_Exception('Category Not Found: ' . $category_slug);
         }
     } else {
         $category = new Category(array('cid' => -1, 'name' => 'All', 'slug' => 'all'));
     }
     $results = Torrent::browse(array('category_cid' => $category->cid, 'window' => 15, 'page' => $page, 'query' => $query, 'sort_col' => $sort_col, 'sort_order' => $sort_order));
     //if (empty($results['torrents'])) throw new Lvc_Exception('No torrents returned. Category: ' . $category->slug. '. Page: '. $page);
     $this->setVar('selected_category', $category);
     $this->setVar('torrents', $results['torrents']);
     $this->setVar('count', $results['count']);
     $this->setVar('query', $query);
     $this->setVar('page', $page);
     $this->setLayoutVar('pageHead', 'Browse Torrents');
     $this->setLayoutVar('pageTitle', 'Browse Torrents');
     if ($category->cid != -1) {
         $this->setLayoutVar('pageHead', $this->getLayoutVar('pageHead') . ': ' . $category->name);
         $this->setLayoutVar('pageTitle', 'Browse Torrents - ' . $category->name);
     }
     if (!empty($query)) {
         $this->setLayoutVar('pageHead', $this->getLayoutVar('pageHead') . ': ' . $query);
         $this->setLayoutVar('pageTitle', 'Search Torrents');
         if (strlen($query) < 3) {
             Flash::set('failure', 'Your search query must be more than 3 characters long.');
         }
     }
     $categories = Category::find_all();
     $this->setVar('categories', $categories);
     $base_url = WWW_BASE_PATH;
     $browse_base = 'browse';
     $search_base = 'search';
     if (empty($query)) {
         $base_url .= $browse_base . '/';
         $base_url .= $category->slug;
     } else {
         $base_url .= $search_base . '/';
         $base_url .= $category->slug . '/';
         $url_query = str_replace(array('/'), '', $query);
         $url_query = strtr($url_query, array('&' => '%26', '#' => '%23', '\\\\' => '%5C'));
         $url_query = urlencode($url_query);
         $base_url .= $url_query;
     }
     $this->setVar('base_url', $base_url);
     $this->setVar('search_base', $search_base);
     $this->setVar('browse_base', $browse_base);
 }