Example #1
0
 public function contactAction()
 {
     $all_categories = Station::getStationsInCategories();
     $audio_stations = \DF\Utilities::columns($all_categories['audio']['stations'], 2);
     $video_stations = $all_categories['video']['stations'];
     $this->view->station_columns = array(array('<i class="icon ' . $all_categories['audio']['icon'] . '"></i> ' . $all_categories['audio']['name'], $audio_stations[0]), array('&nbsp;', $audio_stations[1]), array('<i class="icon ' . $all_categories['video']['icon'] . '"></i> ' . $all_categories['video']['name'], $video_stations));
     $active_podcasts = array_filter(Podcast::fetchArray('name'), function ($row) {
         return $row['is_approved'];
     });
     $this->view->podcasts = \DF\Utilities::columns($active_podcasts, 3);
     $this->view->podcast_social_types = Podcast::getSocialTypes();
 }
Example #2
0
 public function playlistAction()
 {
     $this->doNotRender();
     if ($this->station) {
         $stations = array($this->station);
     } else {
         $all_stations = Station::getStationsInCategories();
         $stations = $all_stations['audio']['stations'];
     }
     $format = strtolower($this->getParam('format', 'pls'));
     switch ($format) {
         // M3U Playlist Format
         case "m3u":
             $m3u_lines = array();
             $m3u_lines[] = '#EXTM3U';
             $i = 0;
             foreach ($stations as $station) {
                 foreach ($station['streams'] as $stream) {
                     if (!$stream['is_active']) {
                         continue;
                     }
                     $m3u_lines[] = '#EXTINF:' . $i . ',PVL! ' . $station['name'] . ': ' . $stream['name'];
                     $m3u_lines[] = $stream['stream_url'];
                     $i++;
                 }
             }
             $m3u_file = implode("\r\n", $m3u_lines);
             header('Content-Type: audio/x-mpegurl');
             header('Content-Disposition: attachment; filename="pvl_stations.m3u"');
             echo $m3u_file;
             break;
             // Euro Truck Simulator 2
         // Euro Truck Simulator 2
         case "ets":
             $ets_lines = array();
             $ets_i = 0;
             foreach ($stations as $station) {
                 foreach ($station['streams'] as $stream) {
                     if (!$stream['is_active'] || !$stream['is_default']) {
                         continue;
                     }
                     $ets_line = array(str_replace('|', '', $stream['stream_url']), str_replace('|', '', $station['name']), str_replace('|', '', $station['genre']), $station['country'] ? strtoupper($station['country']) : 'EN', 128, 1);
                     $ets_lines[] = ' stream_data[' . $ets_i . ']: "' . implode('|', $ets_line) . '"';
                     $ets_i++;
                 }
             }
             $ets_file = "SiiNunit\n{\nlive_stream_def : _nameless.0662.83F8 {\n";
             $ets_file .= " stream_data: " . count($ets_lines) . "\n";
             $ets_file .= implode("\n", $ets_lines);
             $ets_file .= "\n}\n\n}";
             header('Content-Type: text/plain');
             header('Content-Disposition: attachment; filename="live_streams.sii"');
             echo $ets_file;
             break;
             // PLS Playlist Format
         // PLS Playlist Format
         case "pls":
         default:
             $output = array();
             $output[] = '[playlist]';
             $output[] = 'NumberOfEntries=' . count($stations);
             $i = 1;
             foreach ($stations as $station) {
                 foreach ($station['streams'] as $stream) {
                     if (!$stream['is_active']) {
                         continue;
                     }
                     $output[] = 'File' . $i . '=' . $stream['stream_url'];
                     $output[] = 'Title' . $i . '=PVL! ' . $station['name'] . ': ' . $stream['name'];
                     $output[] = 'Length' . $i . '=-1';
                     $output[] = 'Version=2';
                     $i++;
                 }
             }
             header('Content-Type: audio/x-scpls');
             header('Content-Disposition: attachment; filename="pvl_stations.pls"');
             echo implode("\r\n", $output);
             break;
     }
 }
Example #3
-1
 public function listAction()
 {
     $category = $this->getParam('category', 'all');
     if ($category == 'all') {
         $stations_raw = Station::fetchArray();
     } else {
         $cats = Station::getStationsInCategories();
         if (!isset($cats[$category])) {
             return $this->returnError('Category not found.');
         }
         $stations_raw = $cats[$category]['stations'];
     }
     $stations = array();
     foreach ($stations_raw as $row) {
         $stations[] = Station::api($row);
     }
     return $this->returnSuccess($stations);
 }