PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/clip/php/almanahe.php

https://code.google.com/p/hdforall/
PHP | 319 lines | 295 code | 22 blank | 2 comment | 31 complexity | 0ba0fa0d9582b5d011e25d38f96dedda 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 = urldecode($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. </onEnter>
  35. <onRefresh>
  36. setRefreshTime(-1);
  37. itemCount = getPageInfo("itemCount");
  38. </onRefresh>
  39. <mediaDisplay name="threePartsView"
  40. sideLeftWidthPC="0"
  41. sideRightWidthPC="0"
  42. headerImageWidthPC="0"
  43. selectMenuOnRight="no"
  44. autoSelectMenu="no"
  45. autoSelectItem="no"
  46. itemImageHeightPC="0"
  47. itemImageWidthPC="0"
  48. itemXPC="8"
  49. itemYPC="25"
  50. itemWidthPC="45"
  51. itemHeightPC="8"
  52. capXPC="8"
  53. capYPC="25"
  54. capWidthPC="45"
  55. capHeightPC="64"
  56. itemBackgroundColor="0:0:0"
  57. itemPerPage="8"
  58. itemGap="0"
  59. bottomYPC="90"
  60. backgroundColor="0:0:0"
  61. showHeader="no"
  62. showDefaultInfo="no"
  63. imageFocus=""
  64. sliding="no"
  65. >
  66. <text align="center" offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="20" fontSize="30" backgroundColor="10:105:150" foregroundColor="100:200:255">
  67. <script>getPageInfo("pageTitle");</script>
  68. </text>
  69. <text align="left" offsetXPC="6" offsetYPC="15" widthPC="100" heightPC="4" fontSize="16" backgroundColor="10:105:150" foregroundColor="100:200:255">
  70. Ap??a??i 2 pentru download, 3 pentru Download Manager
  71. </text>
  72. <text redraw="yes" offsetXPC="85" offsetYPC="12" widthPC="10" heightPC="6" fontSize="20" backgroundColor="10:105:150" foregroundColor="60:160:205">
  73. <script>sprintf("%s / ", focus-(-1))+itemCount;</script>
  74. </text>
  75. <text align="center" redraw="yes"
  76. lines="8" fontSize=17
  77. offsetXPC=55 offsetYPC=58 widthPC=40 heightPC=38
  78. backgroundColor=0:0:0 foregroundColor=200:200:200>
  79. <script>print(annotation); annotation;</script>
  80. </text>
  81. <text redraw="yes" align="center" offsetXPC="55" offsetYPC="52" widthPC="15" heightPC="5" fontSize="17" backgroundColor="10:105:150" foregroundColor="100:200:255">
  82. <script>print(durata); durata;</script>
  83. </text>
  84. <text redraw="yes" align="left" offsetXPC="72" offsetYPC="52" widthPC="30" heightPC="5" fontSize="17" backgroundColor="10:105:150" foregroundColor="100:200:255">
  85. <script>print(pub); pub;</script>
  86. </text>
  87. <text redraw="yes" align="center" offsetXPC="0" offsetYPC="90" widthPC="100" heightPC="8" fontSize="17" backgroundColor="10:105:150" foregroundColor="100:200:255">
  88. <script>print(titlu); titlu;</script>
  89. </text>
  90. <image redraw="yes" offsetXPC=60 offsetYPC=25 widthPC=30 heightPC=25>
  91. <script>print(img); img;</script>
  92. </image>
  93. <idleImage> image/POPUP_LOADING_01.png </idleImage>
  94. <idleImage> image/POPUP_LOADING_02.png </idleImage>
  95. <idleImage> image/POPUP_LOADING_03.png </idleImage>
  96. <idleImage> image/POPUP_LOADING_04.png </idleImage>
  97. <idleImage> image/POPUP_LOADING_05.png </idleImage>
  98. <idleImage> image/POPUP_LOADING_06.png </idleImage>
  99. <idleImage> image/POPUP_LOADING_07.png </idleImage>
  100. <idleImage> image/POPUP_LOADING_08.png </idleImage>
  101. <itemDisplay>
  102. <text align="left" lines="1" offsetXPC=0 offsetYPC=0 widthPC=100 heightPC=100>
  103. <script>
  104. idx = getQueryItemIndex();
  105. focus = getFocusItemIndex();
  106. if(focus==idx)
  107. {
  108. img = getItemInfo(idx,"image");
  109. annotation = getItemInfo(idx, "annotation");
  110. durata = getItemInfo(idx, "durata");
  111. pub = getItemInfo(idx, "pub");
  112. titlu = getItemInfo(idx, "title");
  113. }
  114. getItemInfo(idx, "title");
  115. </script>
  116. <fontSize>
  117. <script>
  118. idx = getQueryItemIndex();
  119. focus = getFocusItemIndex();
  120. if(focus==idx) "16"; else "14";
  121. </script>
  122. </fontSize>
  123. <backgroundColor>
  124. <script>
  125. idx = getQueryItemIndex();
  126. focus = getFocusItemIndex();
  127. if(focus==idx) "10:80:120"; else "-1:-1:-1";
  128. </script>
  129. </backgroundColor>
  130. <foregroundColor>
  131. <script>
  132. idx = getQueryItemIndex();
  133. focus = getFocusItemIndex();
  134. if(focus==idx) "255:255:255"; else "140:140:140";
  135. </script>
  136. </foregroundColor>
  137. </text>
  138. </itemDisplay>
  139. <onUserInput>
  140. <script>
  141. ret = "false";
  142. userInput = currentUserInput();
  143. if (userInput == "pagedown" || userInput == "pageup")
  144. {
  145. idx = Integer(getFocusItemIndex());
  146. if (userInput == "pagedown")
  147. {
  148. idx -= -8;
  149. if(idx &gt;= itemCount)
  150. idx = itemCount-1;
  151. }
  152. else
  153. {
  154. idx -= 8;
  155. if(idx &lt; 0)
  156. idx = 0;
  157. }
  158. print("new idx: "+idx);
  159. setFocusItemIndex(idx);
  160. setItemFocus(0);
  161. redrawDisplay();
  162. "true";
  163. }
  164. if (userInput == "two" || userInput == "2")
  165. {
  166. showIdle();
  167. url="<?php echo $host; ?>" + "/scripts/clip/php/almanahe_link.php?file=" + getItemInfo(getFocusItemIndex(),"download");
  168. movie=getUrl(url);
  169. cancelIdle();
  170. topUrl = "http://127.0.0.1/cgi-bin/scripts/util/download.cgi?link=" + movie + ";name=" + getItemInfo(getFocusItemIndex(),"name");
  171. dlok = loadXMLFile(topUrl);
  172. "true";
  173. }
  174. if (userInput == "three" || userInput == "3")
  175. {
  176. jumpToLink("destination");
  177. "true";
  178. }
  179. ret;
  180. </script>
  181. </onUserInput>
  182. </mediaDisplay>
  183. <item_template>
  184. <mediaDisplay name="threePartsView" idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10">
  185. <idleImage>image/POPUP_LOADING_01.png</idleImage>
  186. <idleImage>image/POPUP_LOADING_02.png</idleImage>
  187. <idleImage>image/POPUP_LOADING_03.png</idleImage>
  188. <idleImage>image/POPUP_LOADING_04.png</idleImage>
  189. <idleImage>image/POPUP_LOADING_05.png</idleImage>
  190. <idleImage>image/POPUP_LOADING_06.png</idleImage>
  191. <idleImage>image/POPUP_LOADING_07.png</idleImage>
  192. <idleImage>image/POPUP_LOADING_08.png</idleImage>
  193. </mediaDisplay>
  194. </item_template>
  195. <destination>
  196. <link>http://127.0.0.1/cgi-bin/scripts/util/level.php
  197. </link>
  198. </destination>
  199. <channel>
  200. <title><?php echo $tit; ?></title>
  201. <menu>main menu</menu>
  202. <?php
  203. $page1=20*($page-1);
  204. //http://www.almanahe.ro/video/videolist/videonew.html?cid=8
  205. $t1=explode("cid=",$search);
  206. $cid=$t1[1];
  207. $post="advanceFromSubmission=1&album_id=&cid=".$cid."&sid=&tags=&user_id=0&action_new=&thumb=yes&keyword=&video_language=&run_length=&video_owner=&video_country=&added_within=&start=".$page1."&advanceFromSubmission=&pg=videonew&video_title=&myvideo=No&myfavoritevideo=No&default=Yes&advanced_keyword=Cuvinte+cheie&search_video_owner=+Nume+utilizator&video_country=&video_language=&run_length=&added_within=";
  208. $ch = curl_init($search);
  209. curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
  210. curl_setopt($ch, CURLOPT_REFERER, $search);
  211. curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL
  212. curl_setopt ($ch, CURLOPT_POST, 1);
  213. curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
  214. $html = curl_exec($ch);
  215. if($page > 1) { ?>
  216. <item>
  217. <?php
  218. $sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
  219. $url = $sThisFile."?query=".($page-1).",";
  220. if($search) {
  221. $url = $url.$search.",".urlencode($tit);
  222. }
  223. ?>
  224. <title>Previous Page</title>
  225. <link><?php echo $url;?></link>
  226. <annotation>Pagina anterioara</annotation>
  227. <image>image/left.jpg</image>
  228. <mediaDisplay name="threePartsView"/>
  229. </item>
  230. <?php } ?>
  231. <?php
  232. function str_between($string, $start, $end){
  233. $string = " ".$string; $ini = strpos($string,$start);
  234. if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini;
  235. return substr($string,$ini,$len);
  236. }
  237. $videos = explode('<div id="videolist_thumb', $html);
  238. unset($videos[0]);
  239. $videos = array_values($videos);
  240. foreach($videos as $video) {
  241. $t1 = explode('href="', $video);
  242. $t2 = explode('"', $t1[1]);
  243. $link = $t2[0];
  244. $t1 = explode('src="', $video);
  245. $t2 = explode('"', $t1[1]);
  246. $image = $t2[0];
  247. $t1 = explode('title="', $video);
  248. $t2 = explode('"', $t1[1]);
  249. $title = $t2[0];
  250. $t1=explode('<span class="clsRunTime">',$video);
  251. $t2=explode('</span>',$t1[1]);
  252. $durata=$t2[0];
  253. $t1=explode('<p>',$video);
  254. $t2=explode('</p>',$t1[3]);
  255. $pub = trim(preg_replace("/(<\/?)(\w+)([^>]*>)/e","",$t2[0]));
  256. $pub=str_replace('&nbsp;','',$pub);
  257. $name = preg_replace('/[^A-Za-z0-9_]/','_',$title).".flv";
  258. $descriere=$title;
  259. echo '
  260. <item>
  261. <title>'.$title.'</title>
  262. <onClick>
  263. <script>
  264. showIdle();
  265. url="'.$host.'/scripts/clip/php/almanahe_link.php?file='.$link.'";
  266. movie=getUrl(url);
  267. cancelIdle();
  268. playItemUrl(movie,10);
  269. </script>
  270. </onClick>
  271. <download>'.$link.'</download>
  272. <name>'.$name.'</name>
  273. <annotation>'.$descriere.'</annotation>
  274. <image>'.$image.'</image>
  275. <durata>'.$durata.'</durata>
  276. <pub>'.$pub.'</pub>
  277. <media:thumbnail url="'.$image.'" />
  278. </item>
  279. ';
  280. }
  281. ?>
  282. <item>
  283. <?php
  284. $sThisFile = 'http://127.0.0.1'.$_SERVER['SCRIPT_NAME'];
  285. $url = $sThisFile."?query=".($page+1).",";
  286. if($search) {
  287. $url = $url.$search.",".urlencode($tit);
  288. }
  289. ?>
  290. <title>Next Page</title>
  291. <link><?php echo $url;?></link>
  292. <annotation>Pagina urmatoare</annotation>
  293. <image>image/right.jpg</image>
  294. <mediaDisplay name="threePartsView"/>
  295. </item>
  296. </channel>
  297. </rss>