PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/filme/php/peteava_search.php

https://code.google.com/p/hdforall/
PHP | 333 lines | 299 code | 29 blank | 5 comment | 31 complexity | eedf3d2db9bd222951f5dd97cd0b7c7f MD5 | raw file
  1. #!/usr/local/bin/Resource/www/cgi-bin/php
  2. <?php echo "<?xml version='1.0' encoding='UTF8' ?>";
  3. $query = $_GET["query"];
  4. if($query) {
  5. $queryArr = explode(',', $query);
  6. $page = $queryArr[0];
  7. $search = urldecode($queryArr[1]);
  8. }
  9. ?>
  10. <rss version="2.0">
  11. <onEnter>
  12. startitem = "middle";
  13. setRefreshTime(1);
  14. </onEnter>
  15. <onRefresh>
  16. setRefreshTime(-1);
  17. itemCount = getPageInfo("itemCount");
  18. </onRefresh>
  19. <mediaDisplay name="threePartsView"
  20. sideLeftWidthPC="0"
  21. sideRightWidthPC="0"
  22. headerImageWidthPC="0"
  23. selectMenuOnRight="no"
  24. autoSelectMenu="no"
  25. autoSelectItem="no"
  26. itemImageHeightPC="0"
  27. itemImageWidthPC="0"
  28. itemXPC="8"
  29. itemYPC="25"
  30. itemWidthPC="45"
  31. itemHeightPC="8"
  32. capXPC="8"
  33. capYPC="25"
  34. capWidthPC="45"
  35. capHeightPC="64"
  36. itemBackgroundColor="0:0:0"
  37. itemPerPage="8"
  38. itemGap="0"
  39. bottomYPC="90"
  40. backgroundColor="0:0:0"
  41. showHeader="no"
  42. showDefaultInfo="no"
  43. imageFocus=""
  44. sliding="no"
  45. idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10"
  46. >
  47. <text align="center" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="20" fontSize="30" backgroundColor="10:105:150" foregroundColor="100:200:255">
  48. <script>getPageInfo("pageTitle");</script>
  49. </text>
  50. <text align="left" offsetXPC="6" offsetYPC="15" widthPC="100" heightPC="4" fontSize="16" backgroundColor="10:105:150" foregroundColor="100:200:255">
  51. Ap?sa?i 2 pentru download, 3 pentru Download Manager
  52. </text>
  53. <text redraw="yes" offsetXPC="85" offsetYPC="12" widthPC="10" heightPC="6" fontSize="20" backgroundColor="10:105:150" foregroundColor="60:160:205">
  54. <script>sprintf("%s / ", focus-(-1))+itemCount;</script>
  55. </text>
  56. <text align="center" redraw="yes"
  57. lines="10" fontSize=17
  58. offsetXPC=55 offsetYPC=55 widthPC=40 heightPC=42
  59. backgroundColor=0:0:0 foregroundColor=200:200:200>
  60. <script>print(annotation); annotation;</script>
  61. </text>
  62. <image redraw="yes" offsetXPC=60 offsetYPC=22.5 widthPC=30 heightPC=25>
  63. <script>print(img); img;</script>
  64. </image>
  65. <idleImage>image/POPUP_LOADING_01.png</idleImage>
  66. <idleImage>image/POPUP_LOADING_02.png</idleImage>
  67. <idleImage>image/POPUP_LOADING_03.png</idleImage>
  68. <idleImage>image/POPUP_LOADING_04.png</idleImage>
  69. <idleImage>image/POPUP_LOADING_05.png</idleImage>
  70. <idleImage>image/POPUP_LOADING_06.png</idleImage>
  71. <idleImage>image/POPUP_LOADING_07.png</idleImage>
  72. <idleImage>image/POPUP_LOADING_08.png</idleImage>
  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. location = getItemInfo(idx, "location");
  81. annotation = getItemInfo(idx, "annotation");
  82. img = getItemInfo(idx,"image");
  83. }
  84. getItemInfo(idx, "title");
  85. </script>
  86. <fontSize>
  87. <script>
  88. idx = getQueryItemIndex();
  89. focus = getFocusItemIndex();
  90. if(focus==idx) "16"; else "14";
  91. </script>
  92. </fontSize>
  93. <backgroundColor>
  94. <script>
  95. idx = getQueryItemIndex();
  96. focus = getFocusItemIndex();
  97. if(focus==idx) "10:80:120"; else "-1:-1:-1";
  98. </script>
  99. </backgroundColor>
  100. <foregroundColor>
  101. <script>
  102. idx = getQueryItemIndex();
  103. focus = getFocusItemIndex();
  104. if(focus==idx) "255:255:255"; else "140:140:140";
  105. </script>
  106. </foregroundColor>
  107. </text>
  108. </itemDisplay>
  109. <onUserInput>
  110. <script>
  111. ret = "false";
  112. userInput = currentUserInput();
  113. if (userInput == "pagedown" || userInput == "pageup")
  114. {
  115. idx = Integer(getFocusItemIndex());
  116. if (userInput == "pagedown")
  117. {
  118. idx -= -8;
  119. if(idx &gt;= itemCount)
  120. idx = itemCount-1;
  121. }
  122. else
  123. {
  124. idx -= 8;
  125. if(idx &lt; 0)
  126. idx = 0;
  127. }
  128. print("new idx: "+idx);
  129. setFocusItemIndex(idx);
  130. setItemFocus(0);
  131. redrawDisplay();
  132. "true";
  133. }
  134. if (userInput == "two" || userInput == "2")
  135. {
  136. showIdle();
  137. url=getItemInfo(getFocusItemIndex(),"download");
  138. movie=getUrl(url);
  139. cancelIdle();
  140. topUrl = "http://127.0.0.1/cgi-bin/scripts/util/download.cgi?link=" + movie + ";name=" + getItemInfo(getFocusItemIndex(),"name");
  141. dlok = loadXMLFile(topUrl);
  142. "true";
  143. }
  144. if (userInput == "three" || userInput == "3")
  145. {
  146. jumpToLink("destination");
  147. "true";
  148. }
  149. ret;
  150. </script>
  151. </onUserInput>
  152. </mediaDisplay>
  153. <item_template>
  154. <mediaDisplay name="threePartsView" idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10">
  155. <idleImage>image/POPUP_LOADING_01.png</idleImage>
  156. <idleImage>image/POPUP_LOADING_02.png</idleImage>
  157. <idleImage>image/POPUP_LOADING_03.png</idleImage>
  158. <idleImage>image/POPUP_LOADING_04.png</idleImage>
  159. <idleImage>image/POPUP_LOADING_05.png</idleImage>
  160. <idleImage>image/POPUP_LOADING_06.png</idleImage>
  161. <idleImage>image/POPUP_LOADING_07.png</idleImage>
  162. <idleImage>image/POPUP_LOADING_08.png</idleImage>
  163. </mediaDisplay>
  164. </item_template>
  165. <destination>
  166. <link>http://127.0.0.1/cgi-bin/scripts/util/level.php
  167. </link>
  168. </destination>
  169. <channel>
  170. <title>Cautare:<?php echo $search; ?></title>
  171. <menu>main menu</menu>
  172. <?php
  173. $host = "http://127.0.0.1/cgi-bin";
  174. $search = str_replace(' ','%20',$search);
  175. //http://www.peteava.ro/cauta/video/funny%20clips/pagina/1
  176. //http://www.peteava.ro/cauta/video/red/pagina/2/calitate/toate/grupare/toate/perioada/oricand/sectiuni/toate/sorteaza//directie/
  177. $link = "http://www.peteava.ro/cauta/video/".$search."/pagina/".$page."/calitate/toate/grupare/toate/perioada/oricand/sectiuni/toate/sorteaza//directie/";
  178. //echo $link;
  179. $link = "http://www.peteava.ro/cauta/video/".$search."/pagina/".$page;
  180. $html = file_get_contents($link);
  181. if($page > 1) { ?>
  182. <item>
  183. <?php
  184. $sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
  185. $url = $sThisFile."?query=".($page-1).",";
  186. if($search) {
  187. $url = $url.$search;
  188. }
  189. ?>
  190. <title>Previous Page</title>
  191. <link><?php echo $url;?></link>
  192. <annotation>Pagina anterioar?</annotation>
  193. <image>image/left.jpg</image>
  194. <mediaDisplay name="threePartsView"/>
  195. </item>
  196. <?php } ?>
  197. <?php
  198. //$videos = explode('<div class="playListAdded"', $html);
  199. $videos=explode('div class="materialItemContainer"',$html);
  200. unset($videos[0]);
  201. $videos = array_values($videos);
  202. foreach($videos as $video) {
  203. $t1 = explode('<a href="', $video);
  204. $t2 = explode('"', $t1[2]);
  205. $link = $t2[0];
  206. $link = str_replace(' ','%20',$link);
  207. $link = str_replace('[','%5B',$link);
  208. $link = str_replace(']','%5D',$link);
  209. $link = "http://www.peteava.ro".$link;
  210. for ($i=1;$i<6;$i++) {
  211. $t1 = explode('src="', $video);
  212. $t2 = explode('"', $t1[$i]);
  213. $image = $t2[0];
  214. if (strpos($image,"pixel.gif") === false) break;
  215. }
  216. $t1 = explode('title="', $video);
  217. $t2 = explode('"', $t1[2]);
  218. $title = htmlspecialchars_decode($t2[0]);
  219. $link = $host.'/scripts/filme/php/peteava_link.php?file='.$link;
  220. $name = preg_replace('/[^A-Za-z0-9_]/','_',$title).".flv";
  221. $f = "/usr/local/bin/home_menu";
  222. if (file_exists($f)) {
  223. echo '
  224. <item>
  225. <title>'.$title.'</title>
  226. <onClick>
  227. <script>
  228. showIdle();
  229. url="'.$link.'";
  230. movie=getURL(url);
  231. cancelIdle();
  232. storagePath = getStoragePath("tmp");
  233. storagePath_stream = storagePath + "stream.dat";
  234. streamArray = null;
  235. streamArray = pushBackStringArray(streamArray, "");
  236. streamArray = pushBackStringArray(streamArray, "");
  237. streamArray = pushBackStringArray(streamArray, movie);
  238. streamArray = pushBackStringArray(streamArray, movie);
  239. streamArray = pushBackStringArray(streamArray, video/mp4);
  240. streamArray = pushBackStringArray(streamArray, "'.$pg_tit.'");
  241. streamArray = pushBackStringArray(streamArray, "1");
  242. writeStringToFile(storagePath_stream, streamArray);
  243. doModalRss("rss_file:///usr/local/etc/www/cgi-bin/scripts/util/videoRenderer2.rss");
  244. </script>
  245. </onClick>
  246. <download>'.$link.'</download>
  247. <name>'.$name.'</name>
  248. <image>'.$image.'</image>
  249. <annotation>'.$data.'</annotation>
  250. <media:thumbnail url="'.$image.'" />
  251. <mediaDisplay name="threePartsView"/>
  252. </item>
  253. ';
  254. } else {
  255. echo '
  256. <item>
  257. <title>'.$title.'</title>
  258. <onClick>
  259. <script>
  260. showIdle();
  261. url="'.$link.'";
  262. movie=getURL(url);
  263. cancelIdle();
  264. storagePath = getStoragePath("tmp");
  265. storagePath_stream = storagePath + "stream.dat";
  266. streamArray = null;
  267. streamArray = pushBackStringArray(streamArray, "");
  268. streamArray = pushBackStringArray(streamArray, "");
  269. streamArray = pushBackStringArray(streamArray, movie);
  270. streamArray = pushBackStringArray(streamArray, movie);
  271. streamArray = pushBackStringArray(streamArray, video/mp4);
  272. streamArray = pushBackStringArray(streamArray, "'.$pg_tit.'");
  273. streamArray = pushBackStringArray(streamArray, "1");
  274. writeStringToFile(storagePath_stream, streamArray);
  275. doModalRss("rss_file:///usr/local/etc/www/cgi-bin/scripts/util/videoRenderer1.rss");
  276. </script>
  277. </onClick>
  278. <download>'.$link.'</download>
  279. <name>'.$name.'</name>
  280. <image>'.$image.'</image>
  281. <annotation>'.$data.'</annotation>
  282. <media:thumbnail url="'.$image.'" />
  283. <mediaDisplay name="threePartsView"/>
  284. </item>
  285. ';
  286. }
  287. }
  288. ?>
  289. <item>
  290. <?php
  291. $sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
  292. $url = $sThisFile."?query=".($page+1).",";
  293. if($search) {
  294. $url = $url.$search;
  295. }
  296. ?>
  297. <title>Next Page</title>
  298. <link><?php echo $url;?></link>
  299. <annotation>Pagina urm?toare</annotation>
  300. <image>image/right.jpg</image>
  301. <mediaDisplay name="threePartsView"/>
  302. </item>
  303. </channel>
  304. </rss>