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

/scripts/feeds/xVoD/xVoD/php/scraper/kinoto/series.php

http://eboda-hd-for-all-500.googlecode.com/
PHP | 756 lines | 576 code | 81 blank | 99 comment | 43 complexity | e7007f50743f544b8b02bd4057c0113e 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 'KinotoSeriesTemplate.php';
  8. include_once 'KinoToUtil.php';
  9. include_once "../../util/VideoUtil.php";
  10. include_once "../../util/RssScriptUtil.php";
  11. include_once '../../action/Action.php';
  12. include_once '../../action/rss/SaveBookmarkAction.php';
  13. include_once '../../action/rss/DeleteBookmarkAction.php';
  14. define("SCRAPER_URL", SERVER_HOST_AND_PATH . "php/scraper/kinoto/");
  15. //Start session
  16. if(isset($_GET["PHPSESID"])) {
  17. session_id($_GET["PHPSESID"]);
  18. }
  19. session_start();
  20. //Filter user action and redirect to scrap function
  21. if( isset($_GET["search"]) ) {
  22. $type = $_GET["search"];
  23. $pageTitle = base64_decode($_GET["title"]);
  24. fetchSearch($type,$pageTitle);
  25. }else if( isset($_GET["letter"]) ) {
  26. $letter = $_GET["letter"];
  27. $type = "http://kino.to/Series.html";
  28. fetchLetterItems($type,$letter,"Series: " . $letter);
  29. }else if( isset($_GET["serie"]) ) {
  30. $serie = base64_decode($_GET["serie"]);
  31. $title = base64_decode($_GET["title"]);
  32. fetchSerieSeasons($serie,$title);
  33. }else if( isset($_GET["season"]) ) {
  34. $season = base64_decode($_GET["season"]);
  35. $title = base64_decode($_GET["title"]);
  36. fetchSerieSeasonEpisodes($season,$title);
  37. }else if( isset($_GET["episode"]) ) {
  38. $episode = base64_decode($_GET["episode"]);
  39. $title = base64_decode($_GET["title"]);
  40. fetchSerieSeasonEpisodeLinks($episode,$title);
  41. }else if( isset ($_GET["host"])) {
  42. $host = base64_decode($_GET["host"]);
  43. $link = base64_decode($_GET["link"]);
  44. fetchPlayEpisode($host,$link);
  45. }else {
  46. fetchCategories();
  47. }
  48. //------------------------------------------------------------------------------
  49. //------------------------------------------------------------------------------
  50. //------------------------------------------------------------------------------
  51. /**
  52. * Show initial categories.
  53. */
  54. function fetchCategories() {
  55. $template = new KinotoSeriesTemplate();
  56. $letters = array(
  57. "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0"
  58. );
  59. $template->setSearch( array(
  60. resourceString("search_by") . "...",
  61. resourceString("search_by") . "...",
  62. "rss_command://search",
  63. SCRAPER_URL . "series.php?search=%s" . URL_AMP . "title=" . base64_encode(resourceString("search_by") . "...") . URL_AMP . "PHPSESID=" . session_id(),
  64. ""
  65. )
  66. );
  67. foreach ($letters as $letter) {
  68. $template->addItem(
  69. $letter,
  70. resourceString("goto_letter") . $letter,
  71. SCRAPER_URL . "series.php?letter=" . $letter . URL_AMP . "title=" . base64_encode($title) . URL_AMP . "PHPSESID=" . session_id(),
  72. ""
  73. );
  74. }
  75. $template->generateView(KinotoSeriesTemplate::VIEW_CATEGORY );
  76. }
  77. /**
  78. * Fetch search result items.
  79. */
  80. function fetchSearch($type,$pageTitle) {
  81. $template = new KinotoSeriesTemplate();
  82. $content = file_get_contents("http://kino.to/Search.html?q=".$type,false,getExplorerContext(getSiteHash()));
  83. preg_match_all("/series.png(.*)<a onclick\=\"return false;\" href\=\"(.*)\">(.*)<\/a>/U", $content, $links, PREG_SET_ORDER);
  84. if($links) {
  85. foreach ($links as $value) {
  86. $template->addItem(
  87. html_entity_decode(utf8_decode($value[3])),
  88. "",
  89. SCRAPER_URL . "series.php?serie=" . base64_encode($value[2]) . URL_AMP . "title=" . base64_encode($value[3]) . URL_AMP . "PHPSESID=" . session_id(),
  90. ""
  91. );
  92. }
  93. }
  94. $template->generateView(KinotoSeriesTemplate::VIEW_SERIE, "");
  95. }
  96. /**
  97. * Get category movies and pages.
  98. */
  99. function fetchLetterItems($type,$letter,$title) {
  100. $template = new KinotoSeriesTemplate();
  101. $template->setType($type);
  102. $template->setLetter($letter);
  103. //If page equal "x" goto page number list, in other case process actual category page
  104. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  105. $maxPages = $_GET["pages"];
  106. for($i=1;$i<=$maxPages;++$i) {
  107. $template->addItem(
  108. $i,
  109. resourceString("goto_page") . $i,
  110. SCRAPER_URL . "series.php?letter=" . $letter . URL_AMP . "title=" . base64_encode($title) . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages . URL_AMP . "PHPSESID=" . session_id(),
  111. ""
  112. );
  113. }
  114. $template->generateView(KinotoSeriesTemplate::VIEW_PAGE_NUMBERS );
  115. }else {
  116. if(!isset($_GET["page"])) {
  117. $pages = getPages($type,$letter);
  118. $template->setActualPage(1);
  119. $template->setMaxPages($pages[1]);
  120. $content = $pages[0];
  121. }else {
  122. $page = $_GET["page"];
  123. $template->setActualPage($_GET["page"]);
  124. $template->setMaxPages($_GET["pages"]);
  125. $content = file_get_contents(getMovieListLink($type,$letter,$page),false,getExplorerContext(getSiteHash()));
  126. }
  127. //Remove backslashes
  128. $content = str_replace( "\\", "", $content);
  129. //var_dump($content);
  130. preg_match_all("/<a href=\"\/(.*)\" title=\"(.*)\" onclick=\"return false;\">(.*)<\/a>/U", $content, $links, PREG_SET_ORDER);
  131. //var_dump ($links);
  132. if($links) {
  133. foreach ($links as $value) {
  134. $title = html_entity_decode(utf8_decode($value[3]));
  135. $itemUrl = "/".$value[1];
  136. //if( strpos($itemUrl, '"')) {
  137. // $itemUrl = substr($itemUrl, 0, strpos($itemUrl, '"'));
  138. //}
  139. $template->addItem(
  140. $title,
  141. "",
  142. SCRAPER_URL . "series.php?serie=" . base64_encode($itemUrl) . URL_AMP . "title=" . base64_encode($title) . URL_AMP . "PHPSESID=" . session_id(),
  143. ""
  144. );
  145. }
  146. }
  147. $template->generateView(KinotoSeriesTemplate::VIEW_SERIE, "");
  148. }
  149. }
  150. /**
  151. * Show selected serie seasons.
  152. */
  153. function fetchSerieSeasons($serie,$title) {
  154. $template = new KinotoSeriesTemplate();
  155. //Parse serie page
  156. $content = file_get_contents("http://kino.to" . $serie,false,getExplorerContext(getSiteHash()));
  157. //Get image
  158. //var_dump($content);
  159. preg_match("/<div class=\"Grahpics\">(.*)src=\"(.*)\"/U", $content, $image);
  160. $image = $image[2];
  161. $template->setImage($image);
  162. //Get description
  163. $description = strstr($content,"Descriptore");
  164. $description = strstr($description,">");
  165. $description = substr($description, 1, strpos($description, "<")-1);
  166. $template->setDescription($description);
  167. preg_match("/SeasonSelection(.*)<\/select>/siU", $content, $select);
  168. //var_dump($select);
  169. preg_match("/rel\=\"(.*)\"/siU", $select[1], $serieUrl);
  170. $serieUrl = str_replace("&amp;", "&", $serieUrl[1]);
  171. $select[1] = strstr($select[1],"<option value=\"1\"");
  172. if (!$select[1]){
  173. preg_match("/SeasonSelection(.*)<\/select>/siU", $content, $select);
  174. $select[1] = strstr($select[1],"<option value=\"2\"");
  175. }
  176. //var_dump($select[1]);
  177. preg_match_all("/<option value\=\"(.*)\" rel=\"(.*)\"(.*)>(.*)</siU", $select[1], $episodes, PREG_SET_ORDER);
  178. $seasons = array();
  179. foreach ($episodes as $item) {
  180. $season = array(
  181. $item[4],
  182. $item[2],
  183. "http://kino.to/aGET/MirrorByEpisode/" . $serieUrl."&Season=".$item[1]."&Episode=");
  184. $seasons["$item[4]"] = $season;
  185. //Add links
  186. $template->addItem(
  187. strtoupper($item[4]),
  188. "",
  189. SCRAPER_URL . "series.php?season=" . base64_encode($item[4]) . URL_AMP . "PHPSESID=" . session_id(),
  190. ""
  191. );
  192. }
  193. $_SESSION["seasons"] = serialize($seasons);
  194. $_SESSION["serieTitle"] = $title;
  195. $_SESSION["serieImage"] = $image;
  196. $_SESSION["serieDescription"] = $description;
  197. $template->setSeasons($seasons);
  198. $template->generateView(KinotoSeriesTemplate::VIEW_SEASONS, $title);
  199. }
  200. /**
  201. * Show selected serie season episodes.
  202. */
  203. function fetchSerieSeasonEpisodes($season,$title) {
  204. $template = new KinotoSeriesTemplate();
  205. //Recover info and set to template
  206. $seasons = unserialize( $_SESSION["seasons"] );
  207. $template->setSeasons($seasons);
  208. $template->setMovieTitle($_SESSION["serieTitle"]);
  209. $template->setImage($_SESSION["serieImage"]);
  210. $template->setDescription($_SESSION["serieDescription"]);
  211. //Get season episodes and add links
  212. $season = $seasons[$season];
  213. $episodes = explode(",", $season[1]);
  214. $template->setEpisodes($episodes);
  215. $template->setSelectedSeason($season[0]);
  216. foreach ($episodes as $episode) {
  217. $template->addItem(
  218. sprintf("%02d",$episode),
  219. "",
  220. SCRAPER_URL . "series.php?title=" . $episode . URL_AMP . "episode=" . base64_encode($season[2].$episode) . URL_AMP . "PHPSESID=" . session_id(),
  221. ""
  222. );
  223. }
  224. $template->generateView(KinotoSeriesTemplate::VIEW_EPISODES, $_SESSION["serieTitle"]);
  225. }
  226. /**
  227. * Get season episode available mirrors.
  228. * @var $episode Full episode page link.
  229. */
  230. function fetchSerieSeasonEpisodeLinks($episode,$title) {
  231. $template = new KinotoSeriesTemplate();
  232. //Recover info and set to template
  233. $template->setMovieTitle($_SESSION["serieTitle"]);
  234. $template->setImage($_SESSION["serieImage"]);
  235. $template->setDescription($_SESSION["serieDescription"]);
  236. $content = file_get_contents( $episode, false, getExplorerContext(getSiteHash()) );
  237. preg_match_all("/rel=\"(.*)\"/siU", $content, $links, PREG_SET_ORDER);
  238. foreach ($links as $link) {
  239. $link = "http://kino.to/aGET/Mirror/" . html_entity_decode($link[1]);
  240. $content = file_get_contents( $link, false, getExplorerContext(getSiteHash()) );
  241. if( strpos($content, "Megavideo.com") ) {
  242. $host = "Megavideo.com";
  243. }else if( strpos($content, "Bitload.com (Flash)") ) {
  244. $host = "Bitload.com (Flash)";
  245. }else if( strpos($content, "Bitload.com (DivX)") ) {
  246. $host = "Bitload.com (DivX)";
  247. }else if( strpos($content, "Various (Flash)") ) {
  248. $host = "Various (Flash)";
  249. }else if( strpos($content, "Archiv.to (Flash)") ) {
  250. $host = "Archiv.to (Flash)";
  251. }else if( strpos($content, "Archiv.to (DivX)") ) {
  252. $host = "Archiv.to (DivX)";
  253. }else {
  254. $host = false;
  255. }
  256. if($host) {
  257. $template->addItem(
  258. $host,
  259. "",
  260. SCRAPER_URL . "series.php?host=" . base64_encode($host) . URL_AMP . "link=" . base64_encode($link) . URL_AMP . "PHPSESID=" . session_id(),
  261. ""
  262. );
  263. }
  264. }
  265. $template->generateView(KinotoSeriesTemplate::VIEW_EPISODE_DETAIL, $_SESSION["serieTitle"]);
  266. }
  267. function fetchPlayEpisode($host,$link) {
  268. $template = new KinotoSeriesTemplate();
  269. //Recover info and set to template
  270. $template->setMovieTitle($_SESSION["serieTitle"]);
  271. $template->setImage($_SESSION["serieImage"]);
  272. $template->setDescription($_SESSION["serieDescription"]);
  273. $content = file_get_contents( $link, false, getExplorerContext(getSiteHash()) );
  274. switch($host) {
  275. case "Megavideo.com";
  276. addMegavideoLink($template,$content);
  277. break;
  278. case "Bitload.com (Flash)";
  279. addBitloadLink($template,$content);
  280. break;
  281. case "Bitload.com (DivX)";
  282. addBitloadDivxLink($template,$content);
  283. break;
  284. case "Various (Flash)":
  285. addNovamovLink($template,$content);
  286. break;
  287. case "Archiv.to (Flash)":
  288. addArchivToFlash($template,$content);
  289. break;
  290. case "Archiv.to (DivX)":
  291. addArchivToDivx($template,$content);
  292. break;
  293. }
  294. $template->generateView(KinotoSeriesTemplate::VIEW_PLAY, $_SESSION["serieTitle"]);
  295. }
  296. function addMegavideoLink($template,$content) {
  297. $content = str_replace( "\\", "", $content);
  298. preg_match("|www.megavideo.com\/v\/(.*)\"|U", $content, $links);
  299. if($links) {
  300. $megavideo_id = $links[1];
  301. if( COOKIE_STATE_ACTIVATED && $megavideo_id ) {
  302. $array = VideoUtil::generateMegavideoPremiumLink($megavideo_id);
  303. if($array) {
  304. $template->addMediaItem(
  305. $array[0],
  306. "",
  307. $array[1],
  308. "",
  309. $array[2]
  310. );
  311. }
  312. }
  313. }
  314. }
  315. function addNovamovLink($template,$content) {
  316. $content = str_replace( "\\", "", $content);
  317. //Get novamov mirror links
  318. preg_match_all("/http\:\/\/www\.novamov\.com\/video\/(.*)\"/U", $content, $parts, PREG_SET_ORDER);
  319. foreach ($parts as $part) {
  320. $content = file_get_contents("http://www.novamov.com/video/" . $part[1] );
  321. //Get final file link
  322. preg_match_all("|s1\.addVariable\(\"file\"\,\"(.*)\"|U", $content, $newLink);
  323. if($newLink) {
  324. $newLink = $newLink[1];
  325. $newLink = $newLink[0];
  326. $template->addMediaItem(
  327. substr($newLink, strrpos($newLink,"/")+1),
  328. "",
  329. $newLink,
  330. "",
  331. VideoUtil::getEnclosureMimetype($newLink)
  332. );
  333. }
  334. }
  335. }
  336. function addArchivToFlash($template,$content) {
  337. $content = str_replace( "\\", "", $content);
  338. //Get mirror links
  339. if (preg_match_all("/http\:\/\/archiv\.to\/GET\/(.*)\"/U", $content, $parts2, PREG_SET_ORDER)){
  340. foreach ($parts2 as $part2) {
  341. $content = file_get_contents("http://archiv.to/GET/".$part2[1]);
  342. //$content = strstr($content,"</object>");
  343. //Get final file link
  344. preg_match("/value=\"file=(.*)\&(.*)\"/U", $content, $link);
  345. if($link) {
  346. $link = $link[1];
  347. $template->addMediaItem(
  348. substr($link, strrpos($link,"/")+1),
  349. "",
  350. $link,
  351. "",
  352. VideoUtil::getEnclosureMimetype($link)
  353. );
  354. }
  355. }
  356. }
  357. else{
  358. preg_match_all("/http\:\/\/archiv\.to\/view\/flv\/(.*)\"/U", $content, $parts, PREG_SET_ORDER);
  359. foreach ($parts as $part) {
  360. $content = file_get_contents("http://archiv.to/view/flv/".$part[1]);
  361. //$content = strstr($content,"</object>");
  362. //Get final file link
  363. preg_match("/value=\"file=(.*)\&(.*)\"/U", $content, $link);
  364. if($link) {
  365. $link = $link[1];
  366. $template->addMediaItem(
  367. substr($link, strrpos($link,"/")+1),
  368. "",
  369. $link,
  370. "",
  371. VideoUtil::getEnclosureMimetype($link)
  372. );
  373. }
  374. }
  375. }
  376. }
  377. function addArchivToDivx($template,$content) {
  378. $content = str_replace( "\\", "", $content);
  379. if (preg_match_all("/http\:\/\/archiv\.to\/GET\/(.*)\"/U", $content, $parts2, PREG_SET_ORDER)){
  380. foreach ($parts2 as $part2) {
  381. $content = file_get_contents("http://archiv.to/GET/".$part2[1]);
  382. //$content = strstr($content,"</object>");
  383. //Get final file link
  384. preg_match("/value=\"(.*)\" name=\"src\"/U", $content, $link);
  385. if($link) {
  386. $link = $link[1];
  387. $template->addMediaItem(
  388. substr($link, strrpos($link,"/")+1),
  389. "",
  390. $link,
  391. "",
  392. VideoUtil::getEnclosureMimetype($link)
  393. );
  394. }
  395. }
  396. }
  397. else {
  398. //Get mirror links
  399. preg_match_all("/http\:\/\/archiv\.to\/view\/divx\/(.*)\"/U", $content, $parts, PREG_SET_ORDER);
  400. foreach ($parts as $part) {
  401. $content = file_get_contents("http://archiv.to/view/divx/".$part[1]);
  402. //$content = strstr($content,"</object>");
  403. //Get final file link
  404. preg_match("/value=\"(.*)\" name=\"src\"/U", $content, $link);
  405. if($link) {
  406. $link = $link[1];
  407. $template->addMediaItem(
  408. substr($link, strrpos($link,"/")+1),
  409. "",
  410. $link,
  411. "",
  412. VideoUtil::getEnclosureMimetype($link)
  413. );
  414. }
  415. }
  416. }
  417. }
  418. function addBitloadLink($template,$content) {
  419. $content = str_replace( "\\", "", $content);
  420. if (preg_match_all("/http\:\/\/www\.mystream\.to\/file-(.*)-(.*)-(.*)\"/U", $content, $parts2, PREG_SET_ORDER)){
  421. foreach ($parts2 as $part2) {
  422. $content = getHeadersFlash('http://www.bitload.com/f/'.$part2[1]."/".$part2[2].'?m=def&c=free');
  423. preg_match("/Set-Cookie: PHPSESSID=(.*); path=\//", $headers[4], $sessionid);
  424. $content = file_get_contents("http://www.bitload.com/f/".$part2[1]."/".$part2[2]."?m=def&c=free&PHPSESSID=".$sessionid);
  425. //Get final file link
  426. preg_match_all("/autoPlay\":false,\"url\"\:\"(.*)\"/U", $content, $newLink);
  427. if($newLink) {
  428. $newLink = $newLink[1];
  429. $newLink = $newLink[0];
  430. $template->addMediaItem(
  431. substr($newLink, strrpos($newLink,"/")+1),
  432. "",
  433. $newLink,
  434. "",
  435. VideoUtil::getEnclosureMimetype($newLink)
  436. );
  437. }
  438. }
  439. }
  440. else {
  441. preg_match_all("/http\:\/\/www\.bitload\.com\/f\/(.*)\"/U", $content, $parts, PREG_SET_ORDER);
  442. foreach ($parts as $part) {
  443. $content = getHeadersFlash('http://www.bitload.com/f/'.$part[1].'?m=def&c=free');
  444. preg_match("/Set-Cookie: PHPSESSID=(.*); path=\//", $headers[4], $sessionid);
  445. $content = file_get_contents("http://www.bitload.com/f/".$part[1]."?m=def&c=free&PHPSESSID=".$sessionid);
  446. //Get final file link
  447. preg_match_all("/autoPlay\":false,\"url\"\:\"(.*)\"/U", $content, $newLink);
  448. if($newLink) {
  449. $newLink = $newLink[1];
  450. $newLink = $newLink[0];
  451. $template->addMediaItem(
  452. substr($newLink, strrpos($newLink,"/")+1),
  453. "",
  454. $newLink,
  455. "",
  456. VideoUtil::getEnclosureMimetype($newLink)
  457. );
  458. }
  459. }
  460. }
  461. }
  462. function addBitloadDivxLink($template,$content) {
  463. $content = str_replace( "\\", "", $content);
  464. if (preg_match_all("/http\:\/\/www\.mystream\.to\/file-(.*)-(.*)-(.*)\"/U", $content, $parts2, PREG_SET_ORDER)){
  465. foreach ($parts2 as $part2) {
  466. $content = getHeadersDivx('http://www.bitload.com/d/'.$part2[1]."/".$part2[2].'?m=def&c=free');
  467. preg_match("/Set-Cookie: PHPSESSID=(.*); path=\//", $headers[4], $sessionid);
  468. $content = file_get_contents("http://www.bitload.com/d/".$part2[1]."/".$part2[2]."?m=def&c=free&PHPSESSID=".$sessionid);
  469. //Get final file link
  470. preg_match_all("/var url = \'(.*)\'/U", $content, $newLink);
  471. if($newLink) {
  472. $newLink = $newLink[1];
  473. $newLink = $newLink[0];
  474. $template->addMediaItem(
  475. substr($newLink, strrpos($newLink,"/")+1),
  476. "",
  477. $newLink,
  478. "",
  479. VideoUtil::getEnclosureMimetype($newLink)
  480. );
  481. }
  482. }
  483. }
  484. else {
  485. preg_match_all("/http\:\/\/www\.bitload\.com\/d\/(.*)\"/U", $content, $parts, PREG_SET_ORDER);
  486. foreach ($parts as $part) {
  487. $content = getHeadersDivx('http://www.bitload.com/d/'.$part[1].'?m=def&c=free');
  488. preg_match("/Set-Cookie: PHPSESSID=(.*); path=\//", $headers[4], $sessionid);
  489. $content = file_get_contents("http://www.bitload.com/d/".$part[1]."?m=def&c=free&PHPSESSID=".$sessionid);
  490. //Get final file link
  491. preg_match_all("/var url = \'(.*)\'/U", $content, $newLink);
  492. if($newLink) {
  493. $newLink = $newLink[1];
  494. $newLink = $newLink[0];
  495. $template->addMediaItem(
  496. substr($newLink, strrpos($newLink,"/")+1),
  497. "",
  498. $newLink,
  499. "",
  500. VideoUtil::getEnclosureMimetype($newLink)
  501. );
  502. }
  503. }
  504. }
  505. }
  506. //------------------------------------------------------------------------------
  507. //------------------------------------------------------------------------------
  508. /**
  509. * Get number of pages and retrieve first page content.
  510. */
  511. /*function getPages($url,$letter) {
  512. $content = file_get_contents(getMovieListLink($url,$letter),false,getExplorerContext(getSiteHash()));
  513. //Get letter number of entries
  514. preg_match("/\"iTotalDisplayRecords\":\"(.*)\"/U", $content, $numberEntries);
  515. if($numberEntries) {
  516. $numPages = ceil($numberEntries[1] / 25);
  517. }else {
  518. $numPages = 0;
  519. }
  520. return array($content,$numPages);
  521. }
  522. */
  523. function getPages($url,$letter) {
  524. $content = file_get_contents(getMovieListLink($url,$letter),false,getExplorerContext(getSiteHash()));
  525. //Get letter number of entries
  526. preg_match("/\"iTotalDisplayRecords\":\"(.*)\"/U", $content, $numberEntries);
  527. if($numberEntries) {
  528. $numPages = ceil($numberEntries[1] / 25);
  529. }else {
  530. $numPages = 0;
  531. }
  532. $content = str_replace(
  533. array("\\u00e4","\\u00eb","\\u00ef","\\u00f6","\\u00fc","\\u00c4","\\u00cb","\\u00cf","\\u00d6","\\u00dc","\\u00df"),
  534. array("ä","ĂŤ","ĂŻ","Ăś","Ăź","Ä","Ë","Ă?","Ö","Ü","ß"),
  535. $content);
  536. return array(utf8_decode($content),$numPages);
  537. }
  538. /**
  539. * Generate link to get movie list content.
  540. */
  541. function getMovieListLink($url,$letter,$page=null) {
  542. $genreId = substr($url, strrpos($url,"/")+1);
  543. if(!$page) {
  544. $page = 0;
  545. }
  546. //Create url to get data
  547. return "http://kino.to/aGET/List/?".
  548. "sEcho=3" .
  549. "&iColumns=7" .
  550. "&sColumns=".
  551. "&iSortCol_0=2" .
  552. "&iDisplayStart=" . ($page-1)*25 .
  553. "&iDisplayLength=25".
  554. "&iSortingCols=1" .
  555. "&bSortable_0=true" .
  556. "&bSortable_1=true" .
  557. "&bSortable_2=true" .
  558. "&bSortable_3=false".
  559. "&bSortable_4=false" .
  560. "&bSortable_5=false" .
  561. "&bSortable_6=true" .
  562. "&additional=%7B%22foo%22%3A%22bar%22%2C%22fGenre%22%3A%22" .
  563. $genreId .
  564. "%22%2C%22fType%22%3A%22".
  565. "series" .
  566. "%22%2C%22fLetter%22%3A%22" .
  567. $letter .
  568. "%22%7D";
  569. /* return "http://kino.to/aGET/List/?" .
  570. "additional=" . urlencode('{"fType":"series","fLetter":"' . $letter . '"}') . "" .
  571. "&bSortable_0=true" .
  572. "&bSortable_1=true" .
  573. "&bSortable_2=true" .
  574. "&bSortable_3=false" .
  575. "&bSortable_4=false" .
  576. "&bSortable_5=false" .
  577. "&bSortable_6=true" .
  578. "&iColumns=7" .
  579. "&iDisplayLength=25" .
  580. "&iDisplayStart=0" .
  581. "&iSortCol_0=2" .
  582. "&iSortingCols=1" .
  583. "&sColumns=" .
  584. "&sEcho=1" .
  585. "&sSortDir_0=asc";
  586. */
  587. }
  588. function getHeadersFlash($url)
  589. {
  590. $path = parse_url($url);
  591. if (isset($path['query']))
  592. {
  593. $path['path'] .= '?' . $path['query'];
  594. }
  595. if (!isset($path['port']))
  596. {
  597. $path['port'] = 80;
  598. }
  599. $request = "HEAD " . $path['path']. " HTTP/1.1\r\n";
  600. $request .= "Host: " . $path['host'] . "\r\n";
  601. $request .= "Content-type: application/x-www-form-urlencoded\r\n";
  602. $request .= "Cache-Control: no-cache\r\n";
  603. $request .= "User-Agent: MSIE\r\n";
  604. $request .= "Connection: close\r\n";
  605. $request .= "\r\n";
  606. $f = fsockopen($path['host'], $path['port'], $errno, $errstr);
  607. if ($f)
  608. {
  609. fputs($f, $request);
  610. while (!feof($f))
  611. {
  612. $headers[] = fgets($f);
  613. }
  614. preg_match("/Set-Cookie: PHPSESSID=(.*); path=\//", $headers[4], $sessionid);
  615. //var_dump($headers[4]);
  616. $content = file_get_contents($url."&PHPSESSID=".$sessionid);
  617. //var_dump($content);
  618. fclose($f);
  619. }
  620. return $content;
  621. return $headers;
  622. }
  623. function getHeadersDivx($url)
  624. {
  625. $path = parse_url($url);
  626. if (isset($path['query']))
  627. {
  628. $path['path'] .= '?' . $path['query'];
  629. }
  630. if (!isset($path['port']))
  631. {
  632. $path['port'] = 80;
  633. }
  634. $request = "HEAD " . $path['path']. " HTTP/1.1\r\n";
  635. $request .= "Host: " . $path['host'] . "\r\n";
  636. $request .= "Content-type: application/x-www-form-urlencoded\r\n";
  637. $request .= "Cache-Control: no-cache\r\n";
  638. $request .= "User-Agent: MSIE\r\n";
  639. $request .= "Connection: close\r\n";
  640. $request .= "\r\n";
  641. $f = fsockopen($path['host'], $path['port'], $errno, $errstr);
  642. if ($f)
  643. {
  644. fputs($f, $request);
  645. while (!feof($f))
  646. {
  647. $headers[] = fgets($f);
  648. }
  649. preg_match("/Set-Cookie: PHPSESSID=(.*); path=\//", $headers[4], $sessionid);
  650. //var_dump(headers[4]);
  651. $content = file_get_contents($url."&PHPSESSID=".$sessionid);
  652. //var_dump($content);
  653. fclose($f);
  654. }
  655. return $content;
  656. return $headers;
  657. }
  658. ?>