PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/clip/php/trilulilu.php

https://code.google.com/p/hdforall/
PHP | 343 lines | 322 code | 19 blank | 2 comment | 46 complexity | 40c318e1e9eaee160b1ab4b9a3005ce9 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. $query = $_GET["query"];
  5. if($query) {
  6. $queryArr = explode(',', $query);
  7. $page = $queryArr[0];
  8. $search = $queryArr[1];
  9. $tit = urldecode($queryArr[2]);
  10. }
  11. clearstatcache();
  12. if (file_exists("/tmp/usbmounts/sda1/download")) {
  13. $dir = "/tmp/usbmounts/sda1/download/log/";
  14. } elseif (file_exists("/tmp/usbmounts/sdb1/download")) {
  15. $dir = "/tmp/usbmounts/sdb1/download/log/";
  16. } elseif (file_exists("/tmp/usbmounts/sdc1/download")) {
  17. $dir = "/tmp/usbmounts/sdc1/download/log/";
  18. } elseif (file_exists("/tmp/usbmounts/sda2/download")) {
  19. $dir = "/tmp/usbmounts/sda2/download/log/";
  20. } elseif (file_exists("/tmp/usbmounts/sdb2/download")) {
  21. $dir = "/tmp/usbmounts/sdb2/download/log/";
  22. } elseif (file_exists("/tmp/usbmounts/sdc2/download")) {
  23. $dir = "/tmp/usbmounts/sdc1/download/log/";
  24. } elseif (file_exists("/tmp/hdd/volumes/HDD1/download")) {
  25. $dir = "/tmp/hdd/root/log/";
  26. } else {
  27. $dir = "";
  28. }
  29. ?>
  30. <rss version="2.0">
  31. <onEnter>
  32. startitem = "middle";
  33. setRefreshTime(1);
  34. first_time=1;
  35. </onEnter>
  36. <onExit>
  37. setRefreshTime(-1);
  38. </onExit>
  39. <onRefresh>
  40. if(first_time == 1)
  41. {
  42. setRefreshTime(-1);
  43. itemCount = getPageInfo("itemCount");
  44. first_time=0;
  45. }
  46. else if (do_down == 1)
  47. {
  48. rss = readStringFromFile(log_file);
  49. count = 0;
  50. while(1)
  51. {
  52. l= getStringArrayAt(rss,count);
  53. count += 1;
  54. if(l == null)
  55. {
  56. titlu = getStringArrayAt(rss,count-3);
  57. break;
  58. }
  59. }
  60. }
  61. </onRefresh>
  62. <mediaDisplay name="threePartsView"
  63. sideLeftWidthPC="0"
  64. sideRightWidthPC="0"
  65. headerImageWidthPC="0"
  66. selectMenuOnRight="no"
  67. autoSelectMenu="no"
  68. autoSelectItem="no"
  69. itemImageHeightPC="0"
  70. itemImageWidthPC="0"
  71. itemXPC="8"
  72. itemYPC="25"
  73. itemWidthPC="45"
  74. itemHeightPC="8"
  75. capXPC="8"
  76. capYPC="25"
  77. capWidthPC="45"
  78. capHeightPC="64"
  79. itemBackgroundColor="0:0:0"
  80. itemPerPage="8"
  81. itemGap="0"
  82. bottomYPC="90"
  83. backgroundColor="0:0:0"
  84. showHeader="no"
  85. showDefaultInfo="no"
  86. imageFocus=""
  87. sliding="no"
  88. idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10"
  89. >
  90. <text align="center" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="20" fontSize="30" backgroundColor="10:105:150" foregroundColor="100:200:255">
  91. <script>getPageInfo("pageTitle");</script>
  92. </text>
  93. <text align="left" offsetXPC="6" offsetYPC="15" widthPC="100" heightPC="4" fontSize="16" backgroundColor="10:105:150" foregroundColor="100:200:255">
  94. Ap??a??i 2 pentru download, 3 pentru Download Manager
  95. </text>
  96. <text redraw="yes" offsetXPC="85" offsetYPC="12" widthPC="10" heightPC="6" fontSize="20" backgroundColor="10:105:150" foregroundColor="60:160:205">
  97. <script>sprintf("%s / ", focus-(-1))+itemCount;</script>
  98. </text>
  99. <text align="center" redraw="yes"
  100. lines="8" fontSize=17
  101. offsetXPC=55 offsetYPC=58 widthPC=40 heightPC=38
  102. backgroundColor=0:0:0 foregroundColor=200:200:200>
  103. <script>print(annotation); annotation;</script>
  104. </text>
  105. <text redraw="yes" align="center" offsetXPC="60" offsetYPC="52" widthPC="30" heightPC="5" fontSize="17" backgroundColor="10:105:150" foregroundColor="100:200:255">
  106. <script>print(durata); durata;</script>
  107. </text>
  108. <text redraw="yes" align="center" offsetXPC="0" offsetYPC="90" widthPC="100" heightPC="8" fontSize="17" backgroundColor="10:105:150" foregroundColor="100:200:255">
  109. <script>print(titlu); titlu;</script>
  110. </text>
  111. <image redraw="yes" offsetXPC=60 offsetYPC=25 widthPC=30 heightPC=25>
  112. <script>print(img); img;</script>
  113. </image>
  114. <idleImage> image/POPUP_LOADING_01.png </idleImage>
  115. <idleImage> image/POPUP_LOADING_02.png </idleImage>
  116. <idleImage> image/POPUP_LOADING_03.png </idleImage>
  117. <idleImage> image/POPUP_LOADING_04.png </idleImage>
  118. <idleImage> image/POPUP_LOADING_05.png </idleImage>
  119. <idleImage> image/POPUP_LOADING_06.png </idleImage>
  120. <idleImage> image/POPUP_LOADING_07.png </idleImage>
  121. <idleImage> image/POPUP_LOADING_08.png </idleImage>
  122. <itemDisplay>
  123. <text align="left" lines="1" offsetXPC=0 offsetYPC=0 widthPC=100 heightPC=100>
  124. <script>
  125. idx = getQueryItemIndex();
  126. focus = getFocusItemIndex();
  127. if(focus==idx)
  128. {
  129. img = getItemInfo(idx,"image");
  130. annotation = getItemInfo(idx, "annotation");
  131. durata = getItemInfo(idx, "durata");
  132. pub = getItemInfo(idx, "pub");
  133. titlu = getItemInfo(idx, "title");
  134. }
  135. getItemInfo(idx, "title");
  136. </script>
  137. <fontSize>
  138. <script>
  139. idx = getQueryItemIndex();
  140. focus = getFocusItemIndex();
  141. if(focus==idx) "16"; else "14";
  142. </script>
  143. </fontSize>
  144. <backgroundColor>
  145. <script>
  146. idx = getQueryItemIndex();
  147. focus = getFocusItemIndex();
  148. if(focus==idx) "10:80:120"; else "-1:-1:-1";
  149. </script>
  150. </backgroundColor>
  151. <foregroundColor>
  152. <script>
  153. idx = getQueryItemIndex();
  154. focus = getFocusItemIndex();
  155. if(focus==idx) "255:255:255"; else "140:140:140";
  156. </script>
  157. </foregroundColor>
  158. </text>
  159. </itemDisplay>
  160. <onUserInput>
  161. <script>
  162. ret = "false";
  163. userInput = currentUserInput();
  164. if (userInput == "pagedown" || userInput == "pageup")
  165. {
  166. idx = Integer(getFocusItemIndex());
  167. if (userInput == "pagedown")
  168. {
  169. idx -= -8;
  170. if(idx &gt;= itemCount)
  171. idx = itemCount-1;
  172. }
  173. else
  174. {
  175. idx -= 8;
  176. if(idx &lt; 0)
  177. idx = 0;
  178. }
  179. print("new idx: "+idx);
  180. setFocusItemIndex(idx);
  181. setItemFocus(0);
  182. redrawDisplay();
  183. ret="true";
  184. }
  185. else if (userInput == "two" || userInput == "2")
  186. {
  187. showIdle();
  188. url="<?php echo $host; ?>" + "/scripts/clip/php/trilulilu_link.php?file=" + getItemInfo(getFocusItemIndex(),"download");
  189. movie=getUrl(url);
  190. topUrl = "http://127.0.0.1/cgi-bin/scripts/util/download.cgi?link=" + movie + ";name=" + getItemInfo(getFocusItemIndex(),"name");
  191. dlok = loadXMLFile(topUrl);
  192. cancelIdle();
  193. do_down=1;
  194. log_file="<?php echo $dir; ?>" + getItemInfo(getFocusItemIndex(),"name") + ".log";
  195. setRefreshTime(2000);
  196. ret="true";
  197. }
  198. else if (userInput == "three" || userInput == "3")
  199. {
  200. jumpToLink("destination");
  201. ret="true";
  202. }
  203. else
  204. {
  205. setRefreshTime(-1);
  206. do_down=0;
  207. ret="false";
  208. }
  209. ret;
  210. </script>
  211. </onUserInput>
  212. </mediaDisplay>
  213. <item_template>
  214. <mediaDisplay name="threePartsView" idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10">
  215. <idleImage>image/POPUP_LOADING_01.png</idleImage>
  216. <idleImage>image/POPUP_LOADING_02.png</idleImage>
  217. <idleImage>image/POPUP_LOADING_03.png</idleImage>
  218. <idleImage>image/POPUP_LOADING_04.png</idleImage>
  219. <idleImage>image/POPUP_LOADING_05.png</idleImage>
  220. <idleImage>image/POPUP_LOADING_06.png</idleImage>
  221. <idleImage>image/POPUP_LOADING_07.png</idleImage>
  222. <idleImage>image/POPUP_LOADING_08.png</idleImage>
  223. </mediaDisplay>
  224. </item_template>
  225. <destination>
  226. <link>http://127.0.0.1/cgi-bin/scripts/util/level.php
  227. </link>
  228. </destination>
  229. <channel>
  230. <title><?php echo $tit; ?></title>
  231. <menu>main menu</menu>
  232. <?php
  233. //http://www.trilulilu.ro/video/cele-mai-recente/azi?offset=0
  234. if (strpos($search,"canal/") === false) {
  235. $page1=30*($page-1);
  236. } else {
  237. $page1=12*($page-1);
  238. }
  239. if ($search == "http://www.trilulilu.ro/video") {
  240. $html=file_get_contents("http://www.trilulilu.ro/video?cele-mai-recente&oricand&offset=".$page1);
  241. } else {
  242. $html=file_get_contents($search."?offset=".$page1);
  243. }
  244. if($page > 1) { ?>
  245. <item>
  246. <?php
  247. $sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
  248. $url = $sThisFile."?query=".($page-1).",";
  249. if($search) {
  250. $url = $url.$search.",".urlencode($tit);
  251. }
  252. ?>
  253. <title>Previous Page</title>
  254. <link><?php echo $url;?></link>
  255. <annotation>Pagina anterioara</annotation>
  256. <image>image/left.jpg</image>
  257. <mediaDisplay name="threePartsView"/>
  258. </item>
  259. <?php } ?>
  260. <?php
  261. $videos = explode('div class="item', $html);
  262. unset($videos[0]);
  263. $videos = array_values($videos);
  264. foreach($videos as $video) {
  265. $t1 = explode('href="', $video);
  266. $t2 = explode('"', $t1[1]);
  267. $link = $t2[0];
  268. $t3 = explode('title="', $video);
  269. $t2 = explode('"', $t3[1]);
  270. $title = trim($t2[0]);
  271. $title = str_replace("&nbsp;","",$title);
  272. $title = str_replace('&quot;',"",$title);
  273. $title=html_entity_decode($title,ENT_QUOTES, "UTF-8");
  274. $t1 = explode('src="', $video);
  275. $t2 = explode('"', $t1[1]);
  276. $image = $t2[0];
  277. if (strpos($image,"pixel.gif") !== false) {
  278. $image="/usr/local/etc/www/cgi-bin/scripts/clip/image/trilulilu.png";
  279. }
  280. $descriere=$title;
  281. $t1=explode('class="duration">',$video);
  282. $t2=explode('<',$t1[1]);
  283. $durata="Durata:".trim($t2[0]);
  284. $name = preg_replace('/[^A-Za-z0-9_]/','_',$title).".flv";
  285. if ((strpos($title,"Vizion") === false) && ($title <> "")) {
  286. echo '
  287. <item>
  288. <title>'.$title.'</title>
  289. <onClick>
  290. <script>
  291. showIdle();
  292. url="'.$host.'/scripts/clip/php/trilulilu_link.php?file='.$link.'";
  293. movie=getUrl(url);
  294. cancelIdle();
  295. playItemUrl(movie,10);
  296. </script>
  297. </onClick>
  298. <download>'.$link.'</download>
  299. <name>'.$name.'</name>
  300. <annotation>'.$descriere.'</annotation>
  301. <image>'.$image.'</image>
  302. <durata>'.$durata.'</durata>
  303. <media:thumbnail url="'.$image.'" />
  304. </item>
  305. ';
  306. }
  307. }
  308. ?>
  309. <item>
  310. <?php
  311. $sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
  312. $url = $sThisFile."?query=".($page+1).",";
  313. if($search) {
  314. $url = $url.$search.",".urlencode($tit);
  315. }
  316. ?>
  317. <title>Next Page</title>
  318. <link><?php echo $url;?></link>
  319. <annotation>Pagina urmatoare</annotation>
  320. <image>image/right.jpg</image>
  321. <mediaDisplay name="threePartsView"/>
  322. </item>
  323. </channel>
  324. </rss>