Changeset 473
- Timestamp:
- Jan 1, 2013, 12:21:11 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r471 r473 32 32 include_once(dirname(__FILE__).'/../Modules/Network/Network.php'); 33 33 include_once(dirname(__FILE__).'/../Modules/TV/TV.php'); 34 34 include_once(dirname(__FILE__).'/../Modules/OpeningHours/OpeningHours.php'); 35 35 $PrefixMultipliers = array 36 36 ( … … 110 110 /** @var AppModuleManager */ 111 111 var $ModuleManager; 112 var $PathItems; 112 113 113 114 function __construct() … … 125 126 } 126 127 127 function ShowPage($Path) 128 function SearchPage($PathItems, $Pages) 129 { 130 $PathItem = $PathItems[0]; 131 if(array_key_exists($PathItem, $Pages)) 132 { 133 if(is_array($Pages[$PathItem])) 134 { 135 array_shift($PathItems); 136 return(SearchPage($PathItems, $Path[$PathItem])); 137 } else return($this->Pages[$PathItem]); 138 } else return(''); 139 } 140 141 function ShowPage() 128 142 { 129 143 /* @var $Page Page */ 130 if(array_key_exists($Path, $this->Pages))131 {132 $ClassName = $this->Pages[$Path];144 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 145 if($ClassName != '') 146 { 133 147 $Page = new $ClassName(); 134 148 $Page->System = &$this; 135 149 $Page->Database = &$this->Database; 136 150 $Page->GetOutput(); 137 } else echo('Page '. $Path.' not found.');151 } else echo('Page '.implode('/', $this->PathItems).' not found.'); 138 152 } 139 153 … … 283 297 $System->ModuleManager->RegisterModule(new Network($System)); 284 298 $System->ModuleManager->RegisterModule(new TV($System)); 299 $System->ModuleManager->RegisterModule(new ModuleOpeningHours($System)); 285 300 $System->ModuleManager->StartAll(); 286 301 } -
trunk/Common/Page.php
r471 r473 1 1 <?php 2 3 define('PAGE_NOT_FOUND', 'Stránka nenalezena'); 2 4 3 5 class Page extends Module -
trunk/Modules/TV/TV.php
r471 r473 2 2 3 3 include_once('Common/Global.php'); 4 5 class PagePlayList extends Page6 {7 function Show()8 {9 $this->ClearPage = true;10 11 Header("Content-Type: audio/mpegurl");12 Header("Content-Disposition: attachment; filename=playlist.m3u");13 14 echo('#EXTM3U'."\n");15 if(array_key_exists('id', $_GET))16 {17 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") ');18 if($DbResult->num_rows > 0)19 {20 $Channel = $DbResult->fetch_array();21 echo('#EXTINF:0,'.$Channel['Name']."\n");22 echo($Channel['Stream']."\n");23 }24 } else25 {26 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` ');27 while($Channel = $DbResult->fetch_array())28 {29 echo('#EXTINF:0,'.$Channel['Name']."\n");30 echo($Channel['Stream']."\n");31 }32 }33 }34 }35 4 36 5 class PageIPTV extends Page … … 40 9 41 10 function Show() 11 { 12 if(count($this->System->PathItems) > 1) 13 { 14 if($this->System->PathItems[1] == 'playlist.m3u') return($this->ShowPlayList()); 15 else return(PAGE_NOT_FOUND); 16 } else return($this->ShowChannelList()); 17 } 18 19 function ShowChannelList() 42 20 { 43 21 global $Channels; … … 96 74 return($Output); 97 75 } 76 77 function ShowPlayList() 78 { 79 $this->ClearPage = true; 80 81 Header("Content-Type: audio/mpegurl"); 82 Header("Content-Disposition: attachment; filename=playlist.m3u"); 83 84 echo('#EXTM3U'."\n"); 85 if(array_key_exists('id', $_GET)) 86 { 87 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") '); 88 if($DbResult->num_rows > 0) 89 { 90 $Channel = $DbResult->fetch_array(); 91 echo('#EXTINF:0,'.$Channel['Name']."\n"); 92 echo($Channel['Stream']."\n"); 93 } 94 } else 95 { 96 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` '); 97 while($Channel = $DbResult->fetch_array()) 98 { 99 echo('#EXTINF:0,'.$Channel['Name']."\n"); 100 echo($Channel['Stream']."\n"); 101 } 102 } 103 } 98 104 } 99 105 … … 123 129 parent::Start(); 124 130 $this->System->RegisterPage('tv', 'PageIPTV'); 125 $this->System->RegisterPage('tv/playlist.m3u', 'PagePlayList');126 131 } 127 132 -
trunk/index.php
r470 r473 2 2 3 3 include_once('Common/Global.php'); 4 $ Path= ProcessURL();5 $System->ShowPage( implode('/', $Path));4 $System->PathItems = ProcessURL(); 5 $System->ShowPage(); 6 6 7 7 ?>
Note:
See TracChangeset
for help on using the changeset viewer.