#!/usr/local/bin/Resource/www/cgi-bin/php
<?php echo "<?xml version='1.0' encoding='UTF8' ?>";
error_reporting(0);
$host = "http://127.0.0.1/cgi-bin";
function str_between($string, $start, $end){
	$string = " ".$string; $ini = strpos($string,$start);
	if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini;
	return substr($string,$ini,$len);
}
//http://balancer.digi24.ro/?scope=digi24&type=rtmp&quality=hq&t=1355201126707
$l="http://www.digi24.ro/balancer.new/?scope=digi24&type=rtmp&quality=hq&t=";
$l="http://balancer.digi24.ro/?scope=digi24&type=rtmp&quality=hq&t=";
$h=file_get_contents($l);
$h=str_replace("\\","",$h);
$digi_rtmp=str_between($h,'streamer":"','"');
$digi_file=str_between($h,'file":"','"');
$l="http://www.digi24.ro/balancer.new/?scope=digisport1desk&type=rtmp&quality=hq&t=";
$l="http://balancer.digi24.ro/?scope=digisport1desk&type=rtmp&quality=hq&t=";
$h=file_get_contents($l);
$h=str_replace("\\","",$h);
$digi1_rtmp=str_between($h,'streamer":"','"');
$digi1_file=str_between($h,'file":"','"');
$l="http://www.digi24.ro/balancer.new/?scope=digisport2desk&type=rtmp&quality=hq&t=";
$l="http://balancer.digi24.ro/?scope=digisport2desk&type=rtmp&quality=hq&t=";
$h=file_get_contents($l);
$h=str_replace("\\","",$h);
$digi2_rtmp=str_between($h,'streamer":"','"');
$digi2_file=str_between($h,'file":"','"');
?>
<rss version="2.0">
<onEnter>
  startitem = "middle";
  setRefreshTime(1);
  <?php
  echo 'digi_rtmp="'.$digi_rtmp.'";';
  echo 'digi_file="'.$digi_file.'";';
  echo 'digi1_rtmp="'.$digi1_rtmp.'";';
  echo 'digi1_file="'.$digi1_file.'";';
  echo 'digi2_rtmp="'.$digi2_rtmp.'";';
  echo 'digi2_file="'.$digi2_file.'";';
  ?>
</onEnter>

<onRefresh>
  setRefreshTime(-1);
  itemCount = getPageInfo("itemCount");
</onRefresh>
<mediaDisplay name="threePartsView"
	sideLeftWidthPC="0"
	sideRightWidthPC="0"

	headerImageWidthPC="0"
	selectMenuOnRight="no"
	autoSelectMenu="no"
	autoSelectItem="no"
	itemImageHeightPC="0"
	itemImageWidthPC="0"
	itemXPC="8"
	itemYPC="25"
	itemWidthPC="50"
	itemHeightPC="8"
	capXPC="8"
	capYPC="25"
	capWidthPC="50"
	capHeightPC="64"
	itemBackgroundColor="0:0:0"
	itemPerPage="8"
  itemGap="0"
	bottomYPC="90"
	backgroundColor="0:0:0"
	showHeader="no"
	showDefaultInfo="no"
	imageFocus=""
	sliding="no"
	idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10"
>

  	<text align="center" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="20" fontSize="30" backgroundColor="10:105:150" foregroundColor="100:200:255">
		  <script>getPageInfo("pageTitle");</script>
		</text>

  	<text redraw="yes" offsetXPC="85" offsetYPC="12" widthPC="10" heightPC="6" fontSize="20" backgroundColor="10:105:150" foregroundColor="60:160:205">
		  <script>sprintf("%s / ", focus-(-1))+itemCount;</script>
		</text>
		<image  redraw="yes" offsetXPC=60 offsetYPC=35 widthPC=30 heightPC=30>
  image/tv_radio.png
		</image>
        <idleImage>image/POPUP_LOADING_01.png</idleImage>
        <idleImage>image/POPUP_LOADING_02.png</idleImage>
        <idleImage>image/POPUP_LOADING_03.png</idleImage>
        <idleImage>image/POPUP_LOADING_04.png</idleImage>
        <idleImage>image/POPUP_LOADING_05.png</idleImage>
        <idleImage>image/POPUP_LOADING_06.png</idleImage>
        <idleImage>image/POPUP_LOADING_07.png</idleImage>
        <idleImage>image/POPUP_LOADING_08.png</idleImage>

		<itemDisplay>
			<text align="left" lines="1" offsetXPC=0 offsetYPC=0 widthPC=100 heightPC=100>
				<script>
					idx = getQueryItemIndex();
					focus = getFocusItemIndex();
					if(focus==idx)
					{
					  location = getItemInfo(idx, "location");
					  annotation = getItemInfo(idx, "annotation");
					}
					getItemInfo(idx, "title");
				</script>
				<fontSize>
  				<script>
  					idx = getQueryItemIndex();
  					focus = getFocusItemIndex();
  			    if(focus==idx) "16"; else "14";
  				</script>
				</fontSize>
			  <backgroundColor>
  				<script>
  					idx = getQueryItemIndex();
  					focus = getFocusItemIndex();
  			    if(focus==idx) "10:80:120"; else "-1:-1:-1";
  				</script>
			  </backgroundColor>
			  <foregroundColor>
  				<script>
  					idx = getQueryItemIndex();
  					focus = getFocusItemIndex();
  			    if(focus==idx) "255:255:255"; else "140:140:140";
  				</script>
			  </foregroundColor>
			</text>

		</itemDisplay>

<onUserInput>
<script>
ret = "false";
userInput = currentUserInput();

if (userInput == "pagedown" || userInput == "pageup")
{
  idx = Integer(getFocusItemIndex());
  if (userInput == "pagedown")
  {
    idx -= -8;
    if(idx &gt;= itemCount)
      idx = itemCount-1;
  }
  else
  {
    idx -= 8;
    if(idx &lt; 0)
      idx = 0;
  }

  print("new idx: "+idx);
  setFocusItemIndex(idx);
	setItemFocus(0);
  redrawDisplay();
  "true";
}
ret;
</script>
</onUserInput>
		
	</mediaDisplay>
	
	<item_template>
		<mediaDisplay  name="threePartsView" idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10">
        <idleImage>image/POPUP_LOADING_01.png</idleImage>
        <idleImage>image/POPUP_LOADING_02.png</idleImage>
        <idleImage>image/POPUP_LOADING_03.png</idleImage>
        <idleImage>image/POPUP_LOADING_04.png</idleImage>
        <idleImage>image/POPUP_LOADING_05.png</idleImage>
        <idleImage>image/POPUP_LOADING_06.png</idleImage>
        <idleImage>image/POPUP_LOADING_07.png</idleImage>
        <idleImage>image/POPUP_LOADING_08.png</idleImage>
		</mediaDisplay>
	</item_template>

<channel>
  <title>Digi TV</title>

	<item>
	<title>Digi24</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + digi_file + "," + digi_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>

	<item>
	<title>Digi24 Iasi</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + "digi24iasilive" + "," + digi_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>
	
	<item>
	<title>Digi24 Timisoara</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + "digi24timislive" + "," + digi_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>
	
	<item>
	<title>Digi24 Oradea</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + "digi24oradealive" + "," + digi_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>
	<item>
	<title>DigiSport 1 (numai in reteaua RDS)</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + digi1_file + "," + digi1_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>
<!--
	<item>
	<title>DigiSport 1 (proxy)</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-S%2086.123.226.93:80%20-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + digi1_file + "," + digi1_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>
-->
	<item>
	<title>DigiSport 2 (numai in reteaua RDS)</title>
	<onClick>
	<script>
    movie = "http://127.0.0.1/cgi-bin/translate?stream,Rtmp-options:-W%20http://www.digi24.ro/static_dev/public_theme_v3/mediaplayer/player.swf%20-p%20http://www.digi24.ro%20-y%20" + digi2_file + "," + digi2_rtmp;
    playitemurl(movie,10);
    </script>
    </onClick>
	</item>

</channel>
</rss>
