PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

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