1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Common/Global.php');
|
---|
4 |
|
---|
5 | class PageIPTV extends Page
|
---|
6 | {
|
---|
7 | function __construct(System $System)
|
---|
8 | {
|
---|
9 | parent::__construct($System);
|
---|
10 | $this->Title = 'IPTV';
|
---|
11 | $this->Description = 'Síťová televize';
|
---|
12 | $this->ParentClass = 'PagePortal';
|
---|
13 | }
|
---|
14 |
|
---|
15 | function Show(): string
|
---|
16 | {
|
---|
17 | $Output = 'Stažení přehrávače: <a href="https://www.videolan.org/vlc/">VLC Media Player</a><br/>'.
|
---|
18 | 'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'.
|
---|
19 | 'Zobrazení playlistu ve VLC lze provést pomocí menu <strong>View - Playlist</strong> nebo klávesové zkratky CTRL+L<br/>'.
|
---|
20 | '<br/>'.
|
---|
21 | '<div align="center"><strong>Výpis kanálů:</strong><br>';
|
---|
22 |
|
---|
23 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '.
|
---|
24 | ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")');
|
---|
25 | $DbRow = $DbResult->fetch_row();
|
---|
26 | $PageList = GetPageList('TVChannels', $DbRow[0]);
|
---|
27 |
|
---|
28 | $Output .= $PageList['Output'];
|
---|
29 | $Output .= '<table class="WideTable">';
|
---|
30 |
|
---|
31 | $TableColumns = array(
|
---|
32 | array('Name' => 'Name', 'Title' => 'Jméno stanice'),
|
---|
33 | array('Name' => 'Language', 'Title' => 'Jazyk'),
|
---|
34 | array('Name' => 'Category', 'Title' => 'Zaměření'),
|
---|
35 | array('Name' => 'SourceType', 'Title' => 'Zdroj'),
|
---|
36 | array('Name' => '', 'Title' => 'Ladění'),
|
---|
37 | );
|
---|
38 | $Order = GetOrderTableHeader('TVChannels', $TableColumns, 'Name', 0);
|
---|
39 | $Output .= $Order['Output'];
|
---|
40 |
|
---|
41 | $Query = 'SELECT `TV`.*, `TVGroup`.`Name` AS `Category`, `Language`.`Name` AS `Language` FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '.
|
---|
42 | ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "") '.$Order['SQL'].$PageList['SQLLimit'];
|
---|
43 |
|
---|
44 | $DbResult = $this->Database->query($Query);
|
---|
45 | while ($Line = $DbResult->fetch_assoc())
|
---|
46 | {
|
---|
47 | if ($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>';
|
---|
48 | else
|
---|
49 | if ($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>';
|
---|
50 | else $Line['Show'] = ' ';
|
---|
51 |
|
---|
52 | $Output .= '<tr><td><a href="'.$Line['Homepage'].'">'.$Line['Name'].'</a></td>'.
|
---|
53 | '<td>'.$Line['Language'].'</td>'.
|
---|
54 | '<td>'.$Line['Category'].'</td>'.
|
---|
55 | '<td>'.$Line['SourceType'].'</td>'.
|
---|
56 | '<td>'.$Line['Show'].'</td></tr>';
|
---|
57 | }
|
---|
58 | $Output .= '</table>';
|
---|
59 | $Output .= $PageList['Output'];
|
---|
60 |
|
---|
61 | $Output .= '</div><br/>';
|
---|
62 |
|
---|
63 | $Output .= 'Další online TV na webu: <a href="https://spustit.cz/">Spustit.cz</a><br/>';
|
---|
64 |
|
---|
65 | return $Output;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | class PagePlaylist extends Page
|
---|
70 | {
|
---|
71 | function Show(): string
|
---|
72 | {
|
---|
73 | $this->RawPage = true;
|
---|
74 |
|
---|
75 | Header("Content-Type: audio/mpegurl");
|
---|
76 | Header("Content-Disposition: attachment; filename=playlist.m3u");
|
---|
77 |
|
---|
78 | $Output = '#EXTM3U'."\n";
|
---|
79 | if (array_key_exists('id', $_GET))
|
---|
80 | {
|
---|
81 | $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") ');
|
---|
82 | if ($DbResult->num_rows > 0)
|
---|
83 | {
|
---|
84 | $Channel = $DbResult->fetch_array();
|
---|
85 | $Output .= '#EXTINF:0,'.$Channel['Name']."\n";
|
---|
86 | $Output .= $Channel['Stream']."\n";
|
---|
87 | }
|
---|
88 | } else
|
---|
89 | {
|
---|
90 | $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` ');
|
---|
91 | while ($Channel = $DbResult->fetch_array())
|
---|
92 | {
|
---|
93 | $Output .= '#EXTINF:0,'.$Channel['Name']."\n";
|
---|
94 | $Output .= $Channel['Stream']."\n";
|
---|
95 | }
|
---|
96 | }
|
---|
97 | return $Output;
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | class ModuleTV extends Module
|
---|
102 | {
|
---|
103 | function __construct(System $System)
|
---|
104 | {
|
---|
105 | parent::__construct($System);
|
---|
106 | $this->Name = 'TV';
|
---|
107 | $this->Version = '1.0';
|
---|
108 | $this->Creator = 'Chronos';
|
---|
109 | $this->License = 'GNU/GPLv3';
|
---|
110 | $this->Description = 'Television channels management';
|
---|
111 | $this->Models = array(TVGroup::GetClassName(), TV::GetClassName());
|
---|
112 | }
|
---|
113 |
|
---|
114 | function DoStart(): void
|
---|
115 | {
|
---|
116 | $this->System->RegisterPage(['tv'], 'PageIPTV');
|
---|
117 | $this->System->RegisterPage(['tv', 'playlist.m3u'], 'PagePlaylist');
|
---|
118 | $this->System->FormManager->RegisterClass('TV', array(
|
---|
119 | 'Title' => 'TV kanály',
|
---|
120 | 'Table' => 'TV',
|
---|
121 | 'DefaultSortColumn' => 'Name',
|
---|
122 | 'Items' => array(
|
---|
123 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
124 | 'Frequency' => array('Type' => 'Integer', 'Caption' => 'Frekvence', 'Default' => '', 'Suffix' => 'Hz'),
|
---|
125 | 'Norm' => array('Type' => 'String', 'Caption' => 'Video norma', 'Default' => ''),
|
---|
126 | 'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Web', 'Default' => ''),
|
---|
127 | 'Language' => array('Type' => 'TLanguage', 'Caption' => 'Jazyk', 'Default' => '', 'Null' => true),
|
---|
128 | 'ShortName' => array('Type' => 'String', 'Caption' => 'Zkratka', 'Default' => ''),
|
---|
129 | 'Stream' => array('Type' => 'Hyperlink', 'Caption' => 'Proud', 'Default' => ''),
|
---|
130 | 'StreamWeb' => array('Type' => 'Hyperlink', 'Caption' => 'Proud web', 'Default' => ''),
|
---|
131 | 'SourceType' => array('Type' => 'String', 'Caption' => 'Typ zdroje', 'Default' => ''),
|
---|
132 | 'Category' => array('Type' => 'TTVGroup', 'Caption' => 'Kategorie', 'Default' => '', 'Null' => true),
|
---|
133 | ),
|
---|
134 | ));
|
---|
135 | $this->System->FormManager->RegisterClass('TVGroup', array(
|
---|
136 | 'Title' => 'Skupiny TV kanálů',
|
---|
137 | 'Table' => 'TVGroup',
|
---|
138 | 'DefaultSortColumn' => 'Name',
|
---|
139 | 'Items' => array(
|
---|
140 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
141 | 'Channels' => array('Type' => 'TTVListCategory', 'Caption' => 'Kanály', 'Default' => ''),
|
---|
142 | ),
|
---|
143 | ));
|
---|
144 | $this->System->FormManager->RegisterFormType('TTVGroup', array(
|
---|
145 | 'Type' => 'Reference',
|
---|
146 | 'Table' => 'TVGroup',
|
---|
147 | 'Id' => 'Id',
|
---|
148 | 'Name' => 'Name',
|
---|
149 | 'Filter' => '1',
|
---|
150 | ));
|
---|
151 | $this->System->FormManager->RegisterFormType('TTVListCategory', array(
|
---|
152 | 'Type' => 'ManyToOne',
|
---|
153 | 'Table' => 'TV',
|
---|
154 | 'Id' => 'Id',
|
---|
155 | 'Ref' => 'Category',
|
---|
156 | 'Filter' => '1',
|
---|
157 | ));
|
---|
158 | }
|
---|
159 | }
|
---|
160 |
|
---|
161 | class TVGroup extends Model
|
---|
162 | {
|
---|
163 | static function GetModelDesc(): ModelDesc
|
---|
164 | {
|
---|
165 | $Desc = new ModelDesc(self::GetClassName());
|
---|
166 | $Desc->AddString('Name');
|
---|
167 | return $Desc;
|
---|
168 | }
|
---|
169 | }
|
---|
170 |
|
---|
171 | class TV extends Model
|
---|
172 | {
|
---|
173 | static function GetModelDesc(): ModelDesc
|
---|
174 | {
|
---|
175 | $Desc = new ModelDesc(self::GetClassName());
|
---|
176 | $Desc->AddString('Name');
|
---|
177 | $Desc->AddInteger('Frequency');
|
---|
178 | $Desc->AddString('Norm');
|
---|
179 | $Desc->AddString('Homepage');
|
---|
180 | $Desc->AddReference('Language', Language::GetClassName());
|
---|
181 | $Desc->AddString('ShortName');
|
---|
182 | $Desc->AddString('Stream');
|
---|
183 | $Desc->AddString('StreamWeb');
|
---|
184 | $Desc->AddString('SourceType');
|
---|
185 | $Desc->AddReference('Category', TVGroup::GetClassName());
|
---|
186 | return $Desc;
|
---|
187 | }
|
---|
188 | }
|
---|