PageRenderTime 80ms CodeModel.GetById 68ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/filme/php/iplay_main.php

https://code.google.com/p/hdforall/
PHP | 312 lines | 281 code | 26 blank | 5 comment | 29 complexity | 51ed46950ffed9df56dcb424e599782c MD5 | raw file
  1#!/usr/local/bin/Resource/www/cgi-bin/php
  2<?php echo "<?xml version='1.0' encoding='UTF8' ?>";
  3$host = "http://127.0.0.1/cgi-bin";
  4?>
  5<rss version="2.0">
  6<onEnter>
  7  startitem = "middle";
  8  setRefreshTime(1);
  9</onEnter>
 10
 11<onRefresh>
 12  setRefreshTime(-1);
 13  itemCount = getPageInfo("itemCount");
 14</onRefresh>
 15
 16<mediaDisplay name="threePartsView"
 17	sideLeftWidthPC="0"
 18	sideRightWidthPC="0"
 19	
 20	headerImageWidthPC="0"
 21	selectMenuOnRight="no"
 22	autoSelectMenu="no"
 23	autoSelectItem="no"
 24	itemImageHeightPC="0"
 25	itemImageWidthPC="0"
 26	itemXPC="8"
 27	itemYPC="25"
 28	itemWidthPC="30"
 29	itemHeightPC="8"
 30	capXPC="8"
 31	capYPC="25"
 32	capWidthPC="30"
 33	capHeightPC="64"
 34	itemBackgroundColor="0:0:0"
 35	itemPerPage="8"
 36  itemGap="0"
 37	bottomYPC="90"
 38	backgroundColor="0:0:0"
 39	showHeader="no"
 40	showDefaultInfo="no"
 41	imageFocus=""
 42	sliding="no"
 43	idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10"
 44>
 45		
 46  	<text align="center" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="20" fontSize="30" backgroundColor="10:105:150" foregroundColor="100:200:255">
 47		  <script>getPageInfo("pageTitle");</script>
 48		</text>
 49  	<text align="left" offsetXPC="6" offsetYPC="15" widthPC="75" heightPC="4" fontSize="16" backgroundColor="10:105:150" foregroundColor="100:200:255">
 50    2= adauga la favorite
 51		</text>
 52  	<text redraw="yes" offsetXPC="85" offsetYPC="12" widthPC="10" heightPC="6" fontSize="20" backgroundColor="10:105:150" foregroundColor="60:160:205">
 53		  <script>sprintf("%s / ", focus-(-1))+itemCount;</script>
 54		</text>
 55		<text align="center" redraw="yes"
 56          lines="10" fontSize=17
 57		      offsetXPC=55 offsetYPC=55 widthPC=40 heightPC=42
 58		      backgroundColor=0:0:0 foregroundColor=200:200:200>
 59			<script>print(annotation); annotation;</script>
 60		</text>
 61		<image  redraw="yes" offsetXPC=60 offsetYPC=25 widthPC=30 heightPC=20>
 62         <script>print(image); image;</script>
 63		</image>
 64        <idleImage>image/POPUP_LOADING_01.png</idleImage>
 65        <idleImage>image/POPUP_LOADING_02.png</idleImage>
 66        <idleImage>image/POPUP_LOADING_03.png</idleImage>
 67        <idleImage>image/POPUP_LOADING_04.png</idleImage>
 68        <idleImage>image/POPUP_LOADING_05.png</idleImage>
 69        <idleImage>image/POPUP_LOADING_06.png</idleImage>
 70        <idleImage>image/POPUP_LOADING_07.png</idleImage>
 71        <idleImage>image/POPUP_LOADING_08.png</idleImage>
 72
 73		<itemDisplay>
 74			<text align="left" lines="1" offsetXPC=0 offsetYPC=0 widthPC=100 heightPC=100>
 75				<script>
 76					idx = getQueryItemIndex();
 77					focus = getFocusItemIndex();
 78					if(focus==idx) 
 79					{
 80					  image = getItemInfo(idx, "image");
 81					  annotation = getItemInfo(idx, "annotation");
 82					}
 83					getItemInfo(idx, "title");
 84				</script>
 85				<fontSize>
 86  				<script>
 87  					idx = getQueryItemIndex();
 88  					focus = getFocusItemIndex();
 89  			    if(focus==idx) "16"; else "14";
 90  				</script>
 91				</fontSize>
 92			  <backgroundColor>
 93  				<script>
 94  					idx = getQueryItemIndex();
 95  					focus = getFocusItemIndex();
 96  			    if(focus==idx) "10:80:120"; else "-1:-1:-1";
 97  				</script>
 98			  </backgroundColor>
 99			  <foregroundColor>
100  				<script>
101  					idx = getQueryItemIndex();
102  					focus = getFocusItemIndex();
103  			    if(focus==idx) "255:255:255"; else "140:140:140";
104  				</script>
105			  </foregroundColor>
106			</text>
107
108		</itemDisplay>
109		
110<onUserInput>
111<script>
112ret = "false";
113userInput = currentUserInput();
114
115if (userInput == "pagedown" || userInput == "pageup")
116{
117  idx = Integer(getFocusItemIndex());
118  if (userInput == "pagedown")
119  {
120    idx -= -8;
121    if(idx &gt;= itemCount)
122      idx = itemCount-1;
123  }
124  else
125  {
126    idx -= 8;
127    if(idx &lt; 0)
128      idx = 0;
129  }
130
131  print("new idx: "+idx);
132  setFocusItemIndex(idx);
133	setItemFocus(0);
134  redrawDisplay();
135  "true";
136}
137else if (userInput == "two" || userInput == "2")
138{
139 showIdle();
140 url="http://127.0.0.1/cgi-bin/scripts/filme/php/iplay_add.php?mod=add*" + getItemInfo(getFocusItemIndex(),"link1") + "*" + getItemInfo(getFocusItemIndex(),"title1");
141 dummy=getUrl(url);
142 cancelIdle();
143 redrawDisplay();
144 ret="true";
145}
146ret;
147</script>
148</onUserInput>
149		
150	</mediaDisplay>
151	
152	<item_template>
153		<mediaDisplay  name="threePartsView" idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10">
154        <idleImage>image/POPUP_LOADING_01.png</idleImage>
155        <idleImage>image/POPUP_LOADING_02.png</idleImage>
156        <idleImage>image/POPUP_LOADING_03.png</idleImage>
157        <idleImage>image/POPUP_LOADING_04.png</idleImage>
158        <idleImage>image/POPUP_LOADING_05.png</idleImage>
159        <idleImage>image/POPUP_LOADING_06.png</idleImage>
160        <idleImage>image/POPUP_LOADING_07.png</idleImage>
161        <idleImage>image/POPUP_LOADING_08.png</idleImage>
162		</mediaDisplay>
163
164	</item_template>
165
166<channel>
167	<title>iplay</title>
168	<menu>main menu</menu>
169
170
171<?php
172function str_between($string, $start, $end){ 
173	$string = " ".$string; $ini = strpos($string,$start); 
174	if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; 
175	return substr($string,$ini,$len); 
176}
177//necesita inregistrare pe site
178//seenow.txt are o singura linie de forma
179//username|pass
180$filename = "/usr/local/etc/dvdplayer/iplay.txt";
181$cookie="D://iplay.txt";
182$cookie="/tmp/iplay.txt";
183if (file_exists($filename)) {
184  $handle = fopen($filename, "r");
185  $c = fread($handle, filesize($filename));
186  fclose($handle);
187  $a=explode("|",$c);
188  $a1=str_replace("?","@",$a[0]);
189  $user=urlencode($a1);
190  $pass=trim($a[1]);
191if (!file_exists($cookie)) {
192  $l="http://videobox.iplay.ro/login.php";
193  $post="username=".$user."&password=".$pass;
194  $ch = curl_init();
195  curl_setopt($ch, CURLOPT_URL, $l);
196  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
197  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
198  curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
199  curl_setopt($ch,CURLOPT_REFERER,"http://videobox.iplay.ro/login.php");
200  curl_setopt ($ch, CURLOPT_POST, 1);
201  curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
202  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
203  curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
204  $html = curl_exec($ch);
205  curl_close($ch);
206}
207}
208$page = $_GET["query"];
209//http://videobox.iplay.ro/collections/page:1
210  $link="http://videobox.iplay.ro/collections/page:".$page;
211  $ch = curl_init();
212  curl_setopt($ch, CURLOPT_URL, $link);
213  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
214  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
215  curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
216  curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
217  $html = curl_exec($ch);
218  curl_close($ch);
219if($page > 0) { ?>
220
221<item>
222<?php
223$sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
224$url = $sThisFile."?query=".($page-1);
225?>
226<title>Previous Page</title>
227<link><?php echo $url;?></link>
228<annotation>Pagina anterioar?</annotation>
229<image>image/left.jpg</image>
230<mediaDisplay name="threePartsView"/>
231</item>
232
233
234<?php } ?>
235<?php
236$videos = explode('<li>', $html);
237$c=count($videos);
238if ($c > 0 && $page==0) {
239echo '
240<item>
241<title>Lista serialelor favorite</title>
242<link>'.$host.'/scripts/filme/php/iplay_fav.php</link>
243<annotation>Lista serialelor favorite</annotation>
244<image>/usr/local/etc/www/cgi-bin/scripts/filme/image/series.png</image>
245</item>
246';
247}
248$n=0;
249unset($videos[0]);
250$videos = array_values($videos);
251
252foreach($videos as $video) {
253 $t1=explode('href="',$video);
254 $t2=explode('"',$t1[1]);
255 $link="http://videobox.iplay.ro".$t2[0];
256
257 $t1=explode('src="',$video);
258 $t2=explode('"',$t1[1]);
259 $image=$t2[0];
260
261 $t1=explode('span class="',$video);
262 $t2=explode('>',$t1[1]);
263 $t3=explode('<',$t2[1]);
264 $title1=$t3[0];
265
266 $title=$title1;
267 $link1=$link;
268 $link = 'http://127.0.0.1/cgi-bin/scripts/filme/php/iplay_s.php?file='.urlencode($link).','.urlencode($title1);
269
270    echo '
271    <item>
272    <title>'.$title1.'</title>
273    <link>'.$link.'</link>
274    <annotation>'.$title.'</annotation>
275    <image>'.$image.'</image>
276    <title1>'.urlencode($title).'</title1>
277    <link1>'.urlencode($link1).'</link1>
278    <media:thumbnail url="'.$image.'" />
279    <mediaDisplay name="threePartsView"/>
280    </item>
281    ';
282$n++;
283}
284
285if ($n == 0) {
286$link = "/usr/local/etc/www/cgi-bin/scripts/filme/php/iplay.rss";
287$description="Pentru a accesa acest site trebuie s? ave?i un cont pe iplay.ro. Completa?i userul ?i parola în acest formular ?i apoi ap?sa?i Return, Return dup? care accesa?i din nou aceast? pagin?.";
288
289	  echo '
290	  <item>
291	  <title>Logare</title>
292	  <link>'.$link.'</link>
293	  <annotation>'.$description.'</annotation>
294	  <mediaDisplay name="onePartView" />
295	  </item>
296	  ';
297}
298
299?>
300<item>
301<?php
302$sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
303$url = $sThisFile."?query=".($page+1);
304?>
305<title>Next Page</title>
306<link><?php echo $url;?></link>
307<annotation>Pagina urm?toare</annotation>
308<image>image/right.jpg</image>
309<mediaDisplay name="threePartsView"/>
310</item>
311</channel>
312</rss>