PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/feeds/xVoD/xVoD/php/scraper/kinostreaming/index.php

http://eboda-hd-for-all-500.googlecode.com/
PHP | 238 lines | 204 code | 20 blank | 14 comment | 23 complexity | 79355a1f4bd4b052917a94b67ef4fee4 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
  1. <?php
  2. /*-------------------------
  3. * Developed by Maicros
  4. * GNU/GPL Licensed
  5. * ------------------------*/
  6. include_once '../../config/config.php';
  7. include_once 'KinostreamingTemplate.php';
  8. include_once "../../util/VideoUtil.php";
  9. include_once "../../util/RssScriptUtil.php";
  10. include_once '../../action/Action.php';
  11. include_once '../../action/rss/SaveBookmarkAction.php';
  12. include_once '../../action/rss/DeleteBookmarkAction.php';
  13. define("SCRAPER_URL", SERVER_HOST_AND_PATH . "php/scraper/kinostreaming/");
  14. //Do action
  15. if( isset($_GET["search"]) ) {
  16. $type = $_GET["search"];
  17. $pageTitle = base64_decode($_GET["title"]);
  18. if(isset($_GET["view"])) {
  19. $view = $_GET["view"];
  20. }else {
  21. $view = "";
  22. }
  23. fetchSearch($type,$view,$pageTitle);
  24. }else if( isset($_GET["type"]) ) {
  25. $type = base64_decode($_GET["type"]);
  26. $pageTitle = base64_decode($_GET["title"]);
  27. fetchCategoryItems($type,$pageTitle);
  28. }else if(isset($_GET["item"])) {
  29. $item = base64_decode($_GET["item"]);
  30. $title = base64_decode($_GET["title"]);
  31. $image = base64_decode($_GET["image"]);
  32. fetchMovie($item,$title,$image);
  33. }else {
  34. fetchCategories();
  35. }
  36. //------------------------------------------------------------------------------
  37. //------------------------------------------------------------------------------
  38. function fetchCategories() {
  39. $template = new KinostreamingTemplate();
  40. //Get principal page and parse categories side bar
  41. $content = file_get_contents("http://kinostreaming.com/publ");
  42. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  43. $input = str_replace($newlines, "", utf8_decode( $content) );
  44. preg_match("|<\!-- <block2> -->(.*)<\!-- <\/block2> -->|U", $input, $div);
  45. preg_match_all("|<a href\=\"(.*)\" class\=\"catName\">(.*)<\/a>|U", $div[1], $div, PREG_SET_ORDER);
  46. foreach ($div as $link) {
  47. $template->addItem(
  48. $link[2],
  49. "",
  50. SCRAPER_URL . "index.php?type=" . base64_encode($link[1]) . URL_AMP . "title=" . base64_encode($link[2]),
  51. ""
  52. );
  53. }
  54. $template->generateView(KinostreamingTemplate::VIEW_CATEGORY, "Kinostreaming.com" );
  55. }
  56. function fetchCategoryItems($type,$title) {
  57. $template = new KinostreamingTemplate();
  58. //Start session
  59. if(isset($_GET["PHPSESID"])) {
  60. session_id($_GET["PHPSESID"]);
  61. }
  62. session_start();
  63. //If page equal "x" goto page number list, in other case process actual category page
  64. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  65. $maxPages = $_GET["pages"];
  66. for($i=1;$i<=$maxPages;++$i) {
  67. $template->addItem(
  68. $i,
  69. resourceString("goto_page") . $i,
  70. SCRAPER_URL . "index.php?type=" . base64_encode($type) . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages,
  71. ""
  72. );
  73. }
  74. $template->generateView(KinostreamingTemplate::VIEW_PAGE_NUMBERS );
  75. }else {
  76. if(!isset($_GET["page"])) {
  77. $pages = getPages($type."-1-3");
  78. $template->setActualPage(1);
  79. $template->setMaxPages($pages[1]);
  80. $content = $pages[0];
  81. }else {
  82. $template->setActualPage($_GET["page"]);
  83. $template->setMaxPages($_GET["pages"]);
  84. $content = file_get_contents( $type . "-" . $_GET["page"] . "-3" );
  85. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  86. $content = str_replace($newlines, "", html_entity_decode($content));
  87. }
  88. preg_match_all("/<div class\=\"eTitle\"(.*)><a href\=\"(.*)\">(.*)<\/a>(.*)<img src\=\"(.*)\"/U", $content, $links, PREG_SET_ORDER);
  89. if($links) {
  90. foreach ($links as $value) {
  91. $image = $value[5];
  92. if(!$image) {
  93. $image = XTREAMER_IMAGE_PATH . "background/nocover.jpg";
  94. }
  95. $template->addItem(
  96. utf8_decode($value[3]),
  97. "",
  98. SCRAPER_URL . "index.php?item=" . base64_encode($value[2]) . URL_AMP . "title=" . base64_encode($value[3]) . URL_AMP . "image=" . base64_encode($image) . URL_AMP . "PHPSESID=" . session_id(),
  99. $image
  100. );
  101. }
  102. }
  103. $template->generateView(KinostreamingTemplate::VIEW_MOVIE, "");
  104. }
  105. }
  106. function fetchMovie($item,$title,$image) {
  107. $template = new KinostreamingTemplate();
  108. $template->setMovieTitle($title);
  109. //Start session
  110. if(isset($_GET["PHPSESID"])) {
  111. session_id($_GET["PHPSESID"]);
  112. }
  113. session_start();
  114. //Parse movie page
  115. $content = file_get_contents($item);
  116. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  117. $content = str_replace($newlines, "", utf8_decode( $content) );
  118. if( strpos($content,"<strong>DESCRIPTION</strong>")) {
  119. $content = strstr($content, "<strong>DESCRIPTION</strong>");
  120. $content = strstr($content, "<p>");
  121. $description = substr($content, 0, strrpos($content, "</p>"));
  122. $description = str_replace("<p>", "", $description);
  123. $template->setDescription($description);
  124. }
  125. if( strpos($content, "http://www.megavideo.com/v" ) ) {
  126. $regex = "|www.megavideo.com\/v\/(.*)\"|U";
  127. }else if( strpos($content, "&v=" ) ) {
  128. $regex = "|\&v\=(.*)\"|U";
  129. }else {
  130. $regex = false;
  131. }
  132. if($regex) {
  133. preg_match_all($regex, $content, $links);
  134. if($links && $links[1]) {
  135. $links = $links[1];
  136. $links = array_unique( $links );
  137. foreach ($links as $value) {
  138. //Get megavideo id
  139. if(count_chars($value) > 20 ) {
  140. $megavideo_id = substr($value, 0, -32);
  141. }else {
  142. $megavideo_id = $value;
  143. }
  144. if( COOKIE_STATE_ACTIVATED && $megavideo_id ) {
  145. $array = VideoUtil::generateMegavideoPremiumLink($megavideo_id);
  146. if($array) {
  147. $template->addMediaItem(
  148. $array[0],
  149. $description,
  150. $array[1],
  151. "",
  152. $array[2]
  153. );
  154. }
  155. }
  156. }
  157. }
  158. }
  159. //Get megaupload links
  160. if( strpos($content, "www.megaupload.com/?d=" ) ) {
  161. preg_match_all("|www\.megaupload\.com\/\?d\=(.*)\s?\" class\=\"Stylehopbleu\"|U", $content, $links);
  162. if($links && $links[1]) {
  163. $links = $links[1];
  164. $links = array_unique( $links );
  165. foreach($links as $megaupload_id ) {
  166. if( COOKIE_STATE_ACTIVATED ) {
  167. $array = VideoUtil::generateMegauploadPremiumLink($megaupload_id);
  168. if($array) {
  169. //echo $megavideo_id;
  170. $template->addMediaItem(
  171. $array[0],
  172. $description,
  173. $array[1],
  174. "",
  175. $array[2]
  176. );
  177. }
  178. }
  179. }
  180. }
  181. }
  182. $content = strstr($content,"yapb_cache/");
  183. $image = "http://www.megavideolink.com/wp-content/uploads/" . substr($content, 0, strpos($content, '"'));
  184. $template->setImage($image);
  185. $template->generateView(KinostreamingTemplate::VIEW_MOVIE_DETAIL);
  186. }
  187. //------------------------------------------------------------------------------
  188. //------------------------------------------------------------------------------
  189. function getPages($url){
  190. //Add pages
  191. //<span class='pages'>Page 1 sur 72</span>
  192. $content = file_get_contents($url);
  193. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  194. $content = str_replace($newlines, "", html_entity_decode($content));
  195. $ret = $content;
  196. while($content){
  197. $content = strstr($content,'<a class="swchItem1"');
  198. $content = strstr($content,'class');
  199. if($content && !strpos($content,'<a class="swchItem1"')){
  200. $lastPages = $content;
  201. }
  202. }
  203. preg_match("/spages\('(.*)','(.*)'\)/siU", $lastPages, $pages);
  204. if($pages){
  205. $numPages = (int)trim($pages[1]);
  206. }else{
  207. $numPages = 1;
  208. }
  209. return array($ret,$numPages);
  210. }
  211. ?>