<?php

$HTTP_SCRIPT_ROOT = current(explode('scripts/', 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/')).'scripts/';
$DIR_SCRIPT_ROOT  = current(explode('scripts/', dirname(__FILE__).'/')).'scripts/';

function getPlatformExt() {
	$boardId = @trim(@file_get_contents('/sys/realtek_boards/board_id'));
	if (is_readable('/tmp/model')) {
		return str_replace('XTREAMER', 'Xtreamer ',
			@trim(@file_get_contents('/tmp/model')));
	} else if (is_file('/usr/local/bin/scripts/settings/img/xtreamer_logo.png')) {
		return 'Xtreamer ' . (is_file('/sbin.android') ? 'Prodigy' : 'SW2');
	} else if (is_file('/etc/ICONBIT_COPYRIGHT')) {
		return 'iconBIT ' . @trim(@file_get_contents(
			'/etc/VENDOR_NAME'));
	} else if (is_readable('/usr/local/bin/Resource/model.dat')) {
		return strtolower(@trim(@file_get_contents(
			'/usr/local/bin/Resource/model.dat')));
	} else if (is_dir('/usr/local/etc/mos/www/modules')) {
		return 'mos ' . $boardId;
	} else if (is_dir('/sbin/www')) {
		return 'Xtreamer Unknown ' . $boardId;
	}
		return 'realtek ' . $boardId;
}
$Platform = str_replace(' ', '',strtoupper(getPlatformExt()));
$I_Num    = 0;

if ($Platform == "IXTREAMER" || $Platform == "XTREAMER" || $Platform == "XTREAMERPRO" || $Platform == "XTREAMERDVD" || $Platform == "XTREAMERSW2") {
	$FW_U              = True;
	$itemSize          = 20;
	$idleImageXPC      = 45;
	$idleImageYPC      = 42;
	$idleImageWidthPC  = 10;
	$idleImageHeightPC = 16;
	foreach (range(1,6) as $i) {
		$idleImage .= "
			<idleImage>image/POPUP_LOADING_".$i.".png</idleImage>";
	}
} else if ($Platform == "PRODIGY") {
	$FW_U              = False;
	$itemSize          = 19;
	$idleImageXPC      = 47.6;
	$idleImageYPC      = 46;
	$idleImageWidthPC  = 5;
	$idleImageHeightPC = 8;
	foreach (range(1,8) as $i) {
		$idleImage .= "
			<idleImage>Resource/image/IMAGE_BW_LOGO_LOADING_".$i.".png</idleImage>";
	}

} else {
	$FW_U              = False;
	$itemSize          = 19;
	$idleImageXPC      = 45;
	$idleImageYPC      = 42;
	$idleImageWidthPC  = 10;
	$idleImageHeightPC = 16;
	foreach (range(1,6) as $i) {
		$idleImage .= "
			<idleImage>image/POPUP_LOADING_".$i.".png</idleImage>";
	}
}
// file_put_contents($DIR_SCRIPT_ROOT."model.txt", $Platform);

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-Type: text/xml; charset=utf-8");
header("Pragma: no-cache");
header("Expires: 0");

echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://purl.org/dc/elements/1.1/">


<!-- Functions used in RSS Scope -->
<!-- function loads the item data of the menuitem in focus into variables -->
<loadData>
	FMI = getFocusItemindex(); 
	itemTitle = getItemInfo( FMI , "title"); 
	itemBG = getItemInfo( FMI , "bg");
	itemfile = getItemInfo( FMI , "file");
</loadData>


<!-- Method executed on entry of the page -->
<onEnter>
	showIdle();
    executeScript("loadData");
</onEnter>


<onExit>
	setRefreshTime(-1);
</onExit>

<!-- Method executed when the refreshtime times out  -->
<onRefresh>
	setRefreshTime(-1); 
	executeScript("loadData"); 

	redrawDisplay();
</onRefresh>

<mediaDisplay name="photoView"
				showHeader="no"
				rowCount="19"
				columnCount="1"
				drawItemText="no"
				showDefaultInfo="no"
				itemImageXPC="0"
				itemImageYPC="0"
				itemOffsetXPC="4"
				itemOffsetYPC="2"
				sliding="yes"
				itemWidthPC="19.5"
				itemHeightPC="4"
				itemBorderColor="-1:-1:-1"
				idleImageXPC="'.$idleImageXPC.'"
				idleImageYPC="'.$idleImageYPC.'"
				idleImageWidthPC="'.$idleImageWidthPC.'"
				idleImageHeightPC="'.$idleImageHeightPC.'"
				bottomYPC="88"
				sideTopHeightPC="14"
				imageUnFocus = "null"
				imageParentFocus = "null"
				imageBorderPC="0"
				itemBackgroundColor="0:0:0"
				backgroundColor="-1:-1:-1"
				sideColorBottom="-1:-1:-1"
				sideColorTop="-1:-1:-1"
				fontSize="15">

	'.$idleImage.'

	<backgroundDisplay>
		  <image redraw="no" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="100">
				<script>
					   itemBG;
					   /*getItemInfo( -1 , "bg");*/
				</script>
		  </image>
	</backgroundDisplay>

	<image redraw="no" offsetXPC="62.5" offsetYPC="3.5" widthPC="33" heightPC="5">
		<script>
			if(itemfile != "nil"){
				"'.$DIR_SCRIPT_ROOT.'Xtreamering/image/updateBar.png";
				}
		</script>
	</image>


	<itemDisplay>

	
	   <image redraw="yes" offsetXPC="10" offsetYPC="0" widthPC="100">
			<heightPC>
				<script>
					if( getFocusItemIndex() == getItemInfo(-1,"itemid") )
						160;
					else
						100;
				</script>
			</heightPC>
			<widthPC>
				<script>
					if( getFocusItemIndex() == getItemInfo(-1,"itemid") )
						110;
					else
						100;
				</script>
			</widthPC>
			<offsetXPC>
				<script>
					if( getFocusItemIndex() == getItemInfo(-1,"itemid") )
						-4;
					else
						5;
				</script>
			</offsetXPC>
			<offsetYPC>
				<script>
					if( getFocusItemIndex() == getItemInfo(-1,"itemid") )
						-25;
					else
						0;
				</script>
			</offsetYPC>
			<script>
				title = getItemInfo(-1,"title");
				if( getFocusItemIndex() == getItemInfo(-1,"itemid") ){
					"'.$DIR_SCRIPT_ROOT.'Xtreamering/image/" + title + "_menu_big.png";
				}
				else{
					"'.$DIR_SCRIPT_ROOT.'Xtreamering/image/" + title + "_menu_small.png";
				}
			</script>
	   </image>

	</itemDisplay>



	<onUserInput>
		userInput = currentUserInput();
		
		if (userInput == "one" || userInput == "1")
		{
			if(itemfile == "xlistplay"){
				fileName = "'.$DIR_SCRIPT_ROOT.'xListPlay/install/update.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xListPlay/install/update.php";
					jumpToLink("destination");
				}
			} else			
			if(itemfile == "xlivecz"){
				fileName = "'.$DIR_SCRIPT_ROOT.'xLiveCZ/install/install.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xLiveCZ/install/install.php";
					jumpToLink("destination");
				}
			} else
			if(itemfile == "'.$DIR_SCRIPT_ROOT.'xLive/menu.rss"){
				fileName = "'.$DIR_SCRIPT_ROOT.'xLive/install/dsapac.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xLive/install/dsapac.php";
					jumpToLink("destination");
				}
			} else			
			if(itemfile != "nil"){
				if(itemTitle == "disclaimer"){
					Upgrade("Xtreamering");
				}else{
					Upgrade(itemTitle);
				}
			}
			redrawDisplay();
		}else
			"true";


		setRefreshTime(-1);
		/*redrawDisplay();*/
		setRefreshTime(50);
	</onUserInput>

</mediaDisplay>


<destination>
	<link>
		<script>
			  url;
		</script>
	</link>
</destination>


<channel>
<title>Xtreamering</title>
<menu>Xtreamering</menu>
<itemSize>
      <script>
        '.$itemSize.';
      </script>
</itemSize>

	<item>
		<title>xLive</title>
		<!--link>'.$DIR_SCRIPT_ROOT.'xLive/menu.rss</link-->
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xLive.jpg</bg>
		<file>'.$DIR_SCRIPT_ROOT.'xLive/menu.rss</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xLive/menu.rss";
				if(CheckFile(fileName) == "true"){
					url = "'.$DIR_SCRIPT_ROOT.'xLive/menu.rss";
					jumpToLink("destination");
				}else{
					url = "'.$HTTP_SCRIPT_ROOT.'xLive/install/dsapac.php";
					jumpToLink("destination");
				}
			</script>
		</onClick>
	</item>


	<item>
		<title>xLiveCZ</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xLiveCZ.jpg</bg>
		<file>xlivecz</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				SwitchViewer(7);
				fileName = "'.$DIR_SCRIPT_ROOT.'xLiveCZ/category/czech.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xLiveCZ/category/czech.php";
					jumpToLink("destination");
				}else{
					url = "'.$HTTP_SCRIPT_ROOT.'xLiveCZ/install/install.php";
					jumpToLink("destination");
				}
			</script>
		</onClick>
	</item>
	
	<item>
		<title>xListPlay</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xListPlay.bmp</bg>
		<file>xlistplay</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xListPlay/index.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xListPlay/index.php";
					jumpToLink("destination");
				}else{
					url = "'.$HTTP_SCRIPT_ROOT.'xListPlay/install/update.php";
					jumpToLink("destination");
				}
			</script>
		</onClick>
	</item>
	
	<item>
		<title>BBC - iPlayer</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/BBC - iPlayer.jpg</bg>
		<file>nil</file>
		<link>'.$DIR_SCRIPT_ROOT.'BBC-iPlayer/main.rss</link>
		<itemid>'.$I_Num++.'</itemid>
	</item>
	
	<item>
		<title>xSvtplay</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xSvtplay.jpg</bg>
		<file>nil</file>
		<link>'.$HTTP_SCRIPT_ROOT.'svtplay/main_rss.php</link>
		<itemid>'.$I_Num++.'</itemid>
	</item>
	
	<item>
		<title>xIpla</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xIpla.jpg</bg>
		<file>nil</file>
		<link>'.$HTTP_SCRIPT_ROOT.'xIpla/php/index.php</link>
		<itemid>'.$I_Num++.'</itemid>
	</item>
	
	<item>
		<title>xGrooveShark</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xGrooveShark.bmp</bg>
		<file>'.$DIR_SCRIPT_ROOT.'xGrooveShark/index.php</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xGrooveShark/index.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xGrooveShark/index.php";
					jumpToLink("destination");
				}else{
					writeStringToFile("/tmp/title", "xGrooveShark");
					url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
					jumpToLink("destination");
				}

			</script>
		</onClick>
	</item>

	<item>
		<title>xJukebox</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xJukebox.bmp</bg>
		<file>'.$DIR_SCRIPT_ROOT.'xJukebox/index.php</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xJukebox/index.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xJukebox/index.php";
					jumpToLink("destination");
				}else{
					writeStringToFile("/tmp/title", "xJukebox");
					url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
					jumpToLink("destination");
				}

			</script>
		</onClick>
	</item>

	<item>
		<title>xVoD</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xVoD.bmp</bg>
		<file>'.$DIR_SCRIPT_ROOT.'xVoD/php/index.php</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xVoD/php/index.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xVoD/php/index.php";
					jumpToLink("destination");
				}else{
					writeStringToFile("/tmp/title", "xVoD");
					url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
					jumpToLink("destination");
				}
			</script>
		</onClick>
	</item>



<item>
<title>MyxLive</title>
<link>&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#100;&#108;&#46;&#100;&#114;&#111;&#112;&#98;&#111;&#120;&#46;&#99;&#111;&#109;&#47;&#117;&#47;&#51;&#57;&#52;&#56;&#49;&#53;&#54;&#55;&#47;&#77;&#121;&#120;&#76;&#105;&#118;&#101;&#47;&#111;&#114;&#100;&#110;&#101;&#114;&#47;&#109;&#101;&#110;&#117;&#46;&#114;&#115;&#115;</link>
<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/MyxLive.jpg</bg>
<itemid>'.$I_Num++.'</itemid>
<!--onClick>
<script>
fileName = "'.$DIR_SCRIPT_ROOT.'MyxLive/index.php";
if(CheckFile(fileName) == "true"){
    url = "'.$HTTP_SCRIPT_ROOT.'MyxLive/index.php";
    jumpToLink("destination");
}else{
    writeStringToFile("/tmp/title", "MyxLive");
    url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
    jumpToLink("destination");
}
</script>
</onClick-->

</item>

<item>
		<title>xFacebook</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xFacebook.bmp</bg>
		<file>'.$DIR_SCRIPT_ROOT.'xFacebook/index.php</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xFacebook/index.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xFacebook/index.php";
					jumpToLink("destination");
				}else{
					writeStringToFile("/tmp/title", "xFacebook");
					url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
					jumpToLink("destination");
				}
			</script>
		</onClick>
	</item>

	<item>
		<title>OnAir</title>
		<link>http://live.mvix.net/x_live2/scripts/Xtreamer1.rss</link>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/OnAir.jpg</bg>
		<file>nil</file>
		<itemid>'.$I_Num++.'</itemid>
	</item>

	<item>
		<title>GlavTV</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/GlavTV.jpg</bg>
		<file>nil</file>
		<link>'.$HTTP_SCRIPT_ROOT.'GlavTV/index.php</link>
		<itemid>'.$I_Num++.'</itemid>
	</item>

	<item>
		<title>Tvontop</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/Tvontop.png</bg>
		<file>nil</file>
		<link>'.$HTTP_SCRIPT_ROOT.'TVonTop/index.php</link>
		<itemid>'.$I_Num++.'</itemid>
	</item>

	<item>
		<title>News</title>
		<link>http://live.mvix.net/x_live2/scripts/news.rss</link>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/News.bmp</bg>
		<file>nil</file>
		<itemid>'.$I_Num++.'</itemid>

		<mediaDisplay  name="onePartView" imageLeftSide="image/MVIX_LIVE_MAIN_BG_2.jpg"
			sideLeftWidthPC="10"
            sideRightWidthPC="0"
			sideColorRight="0:0:0"
			sideColorLeft="0:0:0"
            headerImageWidthPC="0"
            headerImageXPC="10"
            headerXPC="10"
            itemImageXPC="12" itemImageYPC="18"
            itemImageHeightPC="8" itemImageWidthPC="7"
            capXPC="8"
            capYPC="14"
            capWidthPC="90"
            capHeightPC="8"
            itemXPC="20"
            itemYPC="18"
            itemHeightPC="8"
            itemWidthPC="60"
            itemPerPage="9"
			backgroundColor="0:0:0"
		/>
		<!--onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'RodnoeTV/showCategories.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'RodnoeTV/showCategories.php";
					jumpToLink("destination");
				}else{
					/*writeStringToFile("/tmp/title", "RodnoeTV");
					url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
					jumpToLink("destination");*/
				}
			</script>
		</onClick-->
	</item>

	<item>
		<title>xGames</title>
		<!--link>'.$HTTP_SCRIPT_ROOT.'xGames/xGames.php</link-->
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/xGames.bmp</bg>
		<file>'.$HTTP_SCRIPT_ROOT.'xGames/xGames.php</file>
		<itemid>'.$I_Num++.'</itemid>
		<onClick>
			<script>
				fileName = "'.$DIR_SCRIPT_ROOT.'xGames/xGames.php";
				if(CheckFile(fileName) == "true"){
					url = "'.$HTTP_SCRIPT_ROOT.'xGames/xGames.php";
					jumpToLink("destination");
				}else{
					writeStringToFile("/tmp/title", "xGames");
					url = "'.$DIR_SCRIPT_ROOT.'Xtreamering/download.rss";
					jumpToLink("destination");
				}
			</script>
		</onClick>
	</item>

	<item>
		<title>Weather</title>
		<link>http://live.mvix.net/x_live2/scripts/map/world.rss</link>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/Weather.jpg</bg>
		<file>nil</file>
		<itemid>'.$I_Num++.'</itemid>
		<mediaDisplay name=photoView
			rowCount=6
			columnCount=3
			drawItemText="yes"
			menuBorderColor="20:20:20"
			sideColorBottom="20:20:20"
			sideColorTop="20:20:20"
			itemImageXPC="10"
			itemOffsetXPC="7"
			backgroundColor="0:0:0"
			sliding="no"
			>
		</mediaDisplay>
	</item>
';
if ($FW_U) {
	echo '
	<item>
		<title>OnlineUpdate</title>
		<link>http://live.mvix.net/x_live2/scripts/upgrade.rss</link>
		<bg>/tmp/usbmounts/sda1/scripts/Xtreamering/image/OnlineUpdate.jpg</bg>
		<file>nil</file>
		<itemid>'.$I_Num++.'</itemid>
	</item>';
}
echo '
	<item>
		<title>xHelp</title>
		<link>http://live.mvix.net/x_live2/scripts/xHelp/xhelp.rss</link>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/help/Help_MainPage.jpg</bg>
		<file>nil</file>
		<itemid>'.$I_Num++.'</itemid>
	</item>

	<item>
		<title>disclaimer</title>
		<bg>'.$DIR_SCRIPT_ROOT.'Xtreamering/image/disclaimer.bmp</bg>
		<itemid>'.$I_Num++.'</itemid>
	</item>


</channel>
</rss>';
?>