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

/hosts/download/videozer_com.php

http://rapidleech.googlecode.com/
PHP | 252 lines | 243 code | 9 blank | 0 comment | 22 complexity | 8a4b41cf4a4343a30d6ac86e082755a7 MD5 | raw file
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3. require_once ("index.html");
  4. exit;
  5. }
  6. class videozer_com extends DownloadClass {
  7. public function Download($link) {
  8. $page = $this->GetPage($link);
  9. is_present ($page, "The page you have requested cannot be found", "Video is not found - Try checking the link.");
  10. is_present ($page, "Video is not available - ", "Video is not available - " . cut_str($page, "Video is not available - ", "\n"));
  11. $page = $this->GetPage(str_replace('videozer.com/video/', 'videozer.com/player_control/settings.php?v=', $link));
  12. is_notpresent ($page, "you still have quota left", "Error: Still have quota left?");
  13. if (!preg_match('/"video":\{"title":"([^"]+)"/i', $page, $tl)) html_error('Video title not found.');
  14. if (!preg_match_all('/\{"d":(false|true),"l":"([^"]+)","u":"([^"]+)"/i', $page, $st)) html_error('Video stream(s) not found.'); //Get streams
  15. $akey = $this->vbb_decode($page);
  16. $stream = array();
  17. for ($i = 0; $i < count($st[0]); $i++) {
  18. $stream[$st[2][$i]] = array(($st[1][$i] == "true" ? true : false), base64_decode($st[3][$i])."&$akey");
  19. }
  20. if (count($stream) > 1) {
  21. if (!empty($_REQUEST['vzr_qs'])) {
  22. $qs = trim($_REQUEST['vzr_qs']);
  23. if (array_key_exists($qs, $stream)) {
  24. $dllink = $stream[$qs][1];
  25. } else {
  26. foreach ($stream as $st => $dt) {
  27. if ($dt[0] == true) {
  28. $qs = $st;
  29. $this->changeMesg(lang(300)."<br />Error: Requested video format not found, using \"$qs\".");
  30. $dllink = $dt[1];
  31. break;
  32. }
  33. }
  34. }
  35. } else {
  36. global $PHP_SELF;
  37. echo "\n<br /><br /><h3 style='text-align: center;'>This video have more than 1 stream, please select one for download.</h4>";
  38. echo "\n<br /><center><form name='dl' action='$PHP_SELF' method='post'>\n";
  39. echo "<select name='vzr_qs' id='vzr_qs'>\n";
  40. foreach ($stream as $st => $da) {
  41. if ($da[0] == true) {
  42. echo "<option selected='selected' value='$st'>$st</option>\n";
  43. } else {
  44. echo "<option value='$st'>$st</option>\n";
  45. }
  46. }
  47. echo "</select>\n";
  48. $data = $this->DefaultParamArr($link);
  49. foreach ( $data as $n => $v )
  50. echo("<input type='hidden' name='$n' id='$n' value='$v' />\n");
  51. if ($_POST ['ytdirect'] == 'on') echo "<input type='hidden' name='ytdirect' id='ytdirect' value='on' />\n";
  52. echo "<input type='submit' name='submit' value='Download Video' />\n";
  53. echo "</form></center>\n</body>\n</html>";
  54. exit;
  55. }
  56. } else {
  57. $qs = array_rand($stream);
  58. $dllink = $stream[$qs][1];
  59. }
  60. if ($_POST ['ytdirect'] == 'on') {
  61. echo "<br /><br /><h4><a style='color:yellow' href='" . urldecode($dllink) . "'>Click here or copy the link to your download manager to download</a></h4>\n";
  62. echo "<input name='dlurl' style='text-align: center; width: 800px; border: 1px solid #55AAFF; background-color: #FFFFFF; padding:3px' value='" . urldecode($dllink) . "' onclick='javascript:this.select();' readonly></input>\n</body>\n</html>";
  63. } else {
  64. $filename = str_replace(Array ("\\", "/", ":", "*", "?", "\"", "<", ">", "|"), "_", html_entity_decode(trim($tl[1]))) . " [$qs]" . ".flv";
  65. $this->RedirectDownload($dllink,$filename,0,0,0,$filename);
  66. }
  67. exit;
  68. }
  69. private function Get_Reply($page) {
  70. if (!function_exists('json_decode')) html_error("Error: Please enable JSON in php.");
  71. $json = substr($page, strpos($page,"\r\n\r\n") + 4);
  72. $json = substr($json, strpos($json, "{"));$json = substr($json, 0, strrpos($json, "}") + 1);
  73. $rply = json_decode($json, true);
  74. if (!$rply || count($rply) == 0) html_error("Error getting json data.");
  75. return $rply;
  76. }
  77. private function vbb_decode($page) {
  78. $json = $this->Get_Reply($page);
  79. $key1 = $key2 = $key3 = false;
  80. if (!$key1 = $json["cfg"]["environment"]["rkts"]) html_error("Error getting keys [1]");
  81. if (!$key2 = $json["cfg"]["login"]["pepper"]) html_error("Error getting keys [2]");
  82. if (!$key3 = $json["cfg"]["ads"]["lightbox2"]["time"]) html_error("Error getting keys [3]");
  83. list ($spn, $outk) = explode(";", $this->hextostr($this->bitDecrypt($json["cfg"]["login"]["spen"], $json["cfg"]["login"]["salt"], 950569)), 2);
  84. if (!$spn || !$outk) html_error("Error parsing link [1]");
  85. $outs = array();
  86. foreach (explode("&",$outk) as $out) {
  87. $tmp = explode("=", $out, 2);
  88. $outs[$tmp[0]] = $tmp[1];
  89. }
  90. $ikey = $this->getikey($outs["ik"]);
  91. $spn = explode('&', $spn);
  92. $akey = "";
  93. $decoded = 0;
  94. foreach ($spn as $value) {
  95. $val = explode('=', $value);
  96. if ($val[1] == 1) {
  97. if (!$ks1 = $json["cfg"]["info"]["sece2"]) break;
  98. $akey .= $val[0].'='.$this->mvDecode($ks1, $key1, $ikey).'&'; // decrypt32byte
  99. } elseif ($val[1] == 2) {
  100. if (!$ks1 = $json["cfg"]["ads"]["g_ads"]["url"]) break;
  101. $akey .= $val[0].'='.$this->bitDecrypt($ks1, $key1, $ikey).'&'; // bitDecrypt
  102. } elseif ($val[1] == 3) {
  103. if (!$ks1 = $json["cfg"]["ads"]["g_ads"]["type"]) break;
  104. $akey .= $val[0].'='.$this->bitDecrypt($ks1, $key1, $ikey,26,25431,56989,93,32589,784152).'&'; // d9300
  105. } elseif ($val[1] == 4) {
  106. if (!$ks1 = $json["cfg"]["ads"]["g_ads"]["time"]) break;
  107. $akey .= $val[0].'='.$this->bitDecrypt($ks1, $key1, $ikey,82,84669,48779,32,65598,115498).'&'; // lion
  108. } elseif ($val[1] == 5) {
  109. if (!$ks1 = $json["cfg"]["login"]["euno"]) break;
  110. $akey .= $val[0].'='.$this->bitDecrypt($ks1, $key2, $ikey,10,12254,95369,39,21544,545555).'&'; // heal
  111. } elseif ($val[1] == 6) {
  112. if (!$ks1 = $json["cfg"]["login"]["sugar"]) break;
  113. $akey .= $val[0].'='.$this->bitDecrypt($ks1, $key3, $ikey,22,66595,17447,52,66852,400595).'&'; // brokeup
  114. } else html_error("Error parsing link [2-?-{$val[0]}-{$val[1]}]");
  115. $decoded++;
  116. }
  117. if ($decoded != count($spn)) html_error("Error parsing link [2-{$val[0]}-{$val[1]}]");
  118. $akey .= "start=0";
  119. return $akey;
  120. }
  121. private function getikey($int) {
  122. switch($int) {
  123. default:html_error("Error getting ikey [$int]");
  124. case 1:return 215678;
  125. case 2:return 516929;
  126. case 3:return 962043;
  127. case 4:return 461752;
  128. case 5:return 141994;
  129. }
  130. }
  131. // Finded at php.net
  132. private function hextostr($x) {
  133. $s='';
  134. foreach(explode("\n",trim(chunk_split($x,2))) as $h) $s.=chr(hexdec($h));
  135. return($s);
  136. }
  137. // Shorter string2bin and bin2String functions by rootwarex
  138. private function string2bin($str) {
  139. for ($i = 0; $i < strlen($str); ++ $i) {
  140. $bin .= str_pad(decbin(hexdec($str{$i})), 4, '0', STR_PAD_LEFT);
  141. }
  142. return $bin;
  143. }
  144. private function bin2String($bin) {
  145. $bin = join($bin);
  146. for ($i = strlen($bin)-4; $i >= 0; $i -= 4) {
  147. $hex .= dechex(bindec(substr($bin, $i, 4)));
  148. }
  149. return strrev($hex);
  150. }
  151. // From megavideo plugin...
  152. // Edited...
  153. private function mvDecode ($str, $key1, $key2) {
  154. $_loc1 = $this->string2bin($str);
  155. $_loc1 = str_split($_loc1);
  156. $_loc6 = array ();
  157. $kx = 0;
  158. for($_loc3 = 0; $_loc3 < 384; ++ $_loc3) {
  159. $key1 = ($key1 * 11 + 77213) % 81371;
  160. $key2 = ($key2 * 17 + 92717) % 192811;
  161. $_loc6 [$_loc3] = ($key1 + $key2) % 128;
  162. }
  163. for($_loc3 = 256; $_loc3 >= 0; -- $_loc3) {
  164. $_loc5 = $_loc6 [$_loc3];
  165. $_loc4 = $_loc3 % 128;
  166. $_loc8 = $_loc1 [$_loc5];
  167. $_loc1 [$_loc5] = $_loc1 [$_loc4];
  168. $_loc1 [$_loc4] = $_loc8;
  169. }
  170. for($_loc3 = 0; $_loc3 < 128; ++ $_loc3) {
  171. $_loc1 [$_loc3] = $_loc1 [$_loc3] ^ $_loc6 [$_loc3 + 256] & 1;
  172. }
  173. $_loc12 = join ( $_loc1, "" );
  174. $_loc7 = array ();
  175. for($_loc3 = 0; $_loc3 < strlen ( $_loc12 ); $_loc3 = $_loc3 + 4) {
  176. $_loc9 = substr ( $_loc12, $_loc3, 4 );
  177. $_loc7 [] = $_loc9;
  178. }
  179. return $this->bin2String($_loc7);
  180. }
  181. private function bitDecrypt($param1, $param2, $param3, $param4 = 11, $param5 = 77213, $param6 = 81371, $param7 = 17, $param8 = 92717, $param9 = 192811) {
  182. $_loc17 = 0;
  183. $_loc18 = 0;
  184. $_loc10 = array();
  185. $_loc10 = $this->string2bin($param1);
  186. $_loc11 = strlen($_loc10) * 2;
  187. $_loc10 = str_split($_loc10);
  188. $_loc12 = array();
  189. $_loc13 = 0;
  190. while ($_loc13 < $_loc11 * 1.5) {
  191. $param2 = ($param2 * $param4 + $param5) % $param6;
  192. $param3 = ($param3 * $param7 + $param8) % $param9;
  193. $_loc12[$_loc13] = ($param2 + $param3) % ($_loc11 * 0.5);
  194. $_loc13++;
  195. }
  196. $_loc13 = $_loc11;
  197. while ($_loc13 >= 0) {
  198. $_loc17 = $_loc12[$_loc13];
  199. $_loc18 = $_loc13 % ($_loc11 * 0.5);
  200. $_loc19 = $_loc10[$_loc17];
  201. $_loc10[$_loc17] = $_loc10[$_loc18];
  202. $_loc10[$_loc18] = $_loc19;
  203. $_loc13 = $_loc13 - 1;
  204. }
  205. $_loc13 = 0;
  206. while ($_loc13 < $_loc11 * 0.5) {
  207. $_loc10[$_loc13] = $_loc10[$_loc13] ^ $_loc12[$_loc13 + $_loc11] & 1;
  208. $_loc13++;
  209. }
  210. $_loc14 = implode($_loc10);
  211. $_loc15 = array();
  212. $_loc13 = 0;
  213. while ($_loc13 < strlen($_loc14)) {
  214. $_loc20 = substr($_loc14, $_loc13, 4);
  215. $_loc15[] = $_loc20;
  216. $_loc13 = $_loc13 + 4;
  217. }
  218. return $this->bin2String($_loc15);
  219. }
  220. }
  221. //[15-4-2011] Written by Th3-822 //Using some code of youtube plugin and it shows direct link to video too. [videobb_com plugin]
  222. //[16-4-2011] Renamed 'videobb' to 'videozer' & Edited error msgs for work with videozer. - Th3-822
  223. //[13-10-2011] Fixed Regexp for getting streams && Added DefaultParamArr in post. - Th3-822
  224. //[26-11-2011] Using info posted by czerep from: http://rapidleech.com/index.php?showtopic=12433 for fix the plugin - Added function from megavideo plugin. - Th3-822
  225. //[04-12-2011] Function mvDecode was called more than 1 time... Fixed. - Th3-822
  226. //[16-12-2011] Added lastest edits from videobb plugin. - Th3-822
  227. //[17-12-2011] Fixed 2 regexps and a typo in a if() && Added shorted string2bin and bin2String functions posted by rootwarex. - Th3-822
  228. //[22-12-2011] Now using json decode for vbb_decode && Fixed again... - Th3-822
  229. ?>