1
0

BitMeTvEngine.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. /* $Id: BitMeTvEngine.php 2833 2007-04-08 11:58:47Z b4rt $ */
  3. /*************************************************************
  4. * TorrentFlux PHP Torrent Manager
  5. * www.torrentflux.com
  6. **************************************************************/
  7. /*
  8. This file is part of TorrentFlux.
  9. TorrentFlux is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13. TorrentFlux is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with TorrentFlux; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. class SearchEngine extends SearchEngineBase
  22. {
  23. function SearchEngine($cfg)
  24. {
  25. $this->mainURL = "www.bitmetv.org";
  26. $this->altURL = "www.bitmetv.org";
  27. $this->mainTitle = "BitMeTv";
  28. $this->engineName = "BitMeTv";
  29. $this->author = "AnglaChel";
  30. $this->version = "1.0-tfb";
  31. $this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,1582.0.html";
  32. $this->Initialize($cfg);
  33. }
  34. function populateMainCategories()
  35. {
  36. $this->mainCatalog["211"] = "70s Shows";
  37. $this->mainCatalog["110"] = "80s Shows";
  38. $this->mainCatalog["86"] = "Anime";
  39. $this->mainCatalog["199"] = "Billiards-Snooker-Pool";
  40. $this->mainCatalog["116"] = "British- UK Comedy";
  41. $this->mainCatalog["231"] = "British - UK Drama";
  42. $this->mainCatalog["215"] = "British Mystery";
  43. $this->mainCatalog["90"] = "Cartoons";
  44. $this->mainCatalog["101"] = "Documentaries";
  45. $this->mainCatalog["195"] = "Fantasy-Supernatural";
  46. $this->mainCatalog["225"] = "News";
  47. $this->mainCatalog["238"] = "OZTV";
  48. $this->mainCatalog["134"] = "Poker";
  49. $this->mainCatalog["99"] = "PSP TV Episodes";
  50. $this->mainCatalog["102"] = "Reality TV - Competitive";
  51. $this->mainCatalog["196"] = "Reality TV - Un-Scripted";
  52. $this->mainCatalog["95"] = "Sci Fi";
  53. $this->mainCatalog["87"] = "Stand-UP Comedy";
  54. $this->mainCatalog["210"] = "Subtitles";
  55. $this->mainCatalog["197"] = "Talk Shows";
  56. $this->mainCatalog["228"] = "Trailers";
  57. $this->mainCatalog["209"] = "Wrestling";
  58. $this->mainCatalog["70"] = "Other TV Episodes";
  59. $this->mainCatalog["1"] = "24";
  60. $this->mainCatalog["84"] = "3rd Rock from the Sun";
  61. $this->mainCatalog["104"] = "The 4400";
  62. $this->mainCatalog["151"] = "7 Days";
  63. $this->mainCatalog["212"] = "According to Jim";
  64. $this->mainCatalog["5"] = "Alias";
  65. $this->mainCatalog["187"] = "Ally McBeal";
  66. $this->mainCatalog["108"] = "The Amazing Race";
  67. $this->mainCatalog["152"] = "American Chopper";
  68. $this->mainCatalog["121"] = "American Dad";
  69. $this->mainCatalog["214"] = "American Idol";
  70. $this->mainCatalog["6"] = "Andromeda";
  71. $this->mainCatalog["9"] = "Angel";
  72. $this->mainCatalog["132"] = "Arrested Development";
  73. $this->mainCatalog["85"] = "Babylon 5";
  74. $this->mainCatalog["12"] = "Battlestar Galactica";
  75. $this->mainCatalog["230"] = "Battlestar Galactica Classic";
  76. $this->mainCatalog["198"] = "Bernie Mac";
  77. $this->mainCatalog["81"] = "Biggest Loser";
  78. $this->mainCatalog["137"] = "Birds of Prey";
  79. $this->mainCatalog["130"] = "Black Books";
  80. $this->mainCatalog["188"] = "Blakes 7";
  81. $this->mainCatalog["153"] = "Bones";
  82. $this->mainCatalog["128"] = "Boston Legal";
  83. $this->mainCatalog["23"] = "Buffy";
  84. $this->mainCatalog["154"] = "Carnivale";
  85. $this->mainCatalog["155"] = "Chappelles Show";
  86. $this->mainCatalog["103"] = "Charlie Jade";
  87. $this->mainCatalog["22"] = "Charmed";
  88. $this->mainCatalog["216"] = "The Chasers War on Everything";
  89. $this->mainCatalog["156"] = "Colbert Report";
  90. $this->mainCatalog["139"] = "Cold Case";
  91. $this->mainCatalog["138"] = "Commander In Chief";
  92. $this->mainCatalog["157"] = "Conan O Brien";
  93. $this->mainCatalog["217"] = "Conviction";
  94. $this->mainCatalog["218"] = "Cops";
  95. $this->mainCatalog["158"] = "Corner Gas";
  96. $this->mainCatalog["200"] = "Criminal Minds";
  97. $this->mainCatalog["201"] = "Crossing Jordan";
  98. $this->mainCatalog["19"] = "CSI";
  99. $this->mainCatalog["232"] = "CSI Miami";
  100. $this->mainCatalog["233"] = "CSI NY";
  101. $this->mainCatalog["131"] = "Curb your Enthusiasim";
  102. $this->mainCatalog["109"] = "Da ALi G Show";
  103. $this->mainCatalog["71"] = "Dark Angel";
  104. $this->mainCatalog["159"] = "Dark Skies";
  105. $this->mainCatalog["202"] = "Dawsons Creek";
  106. $this->mainCatalog["24"] = "Dead Like Me";
  107. $this->mainCatalog["160"] = "Dead Zone";
  108. $this->mainCatalog["105"] = "Deadwood";
  109. $this->mainCatalog["75"] = "Desperate Housewives";
  110. $this->mainCatalog["88"] = "Dr Who";
  111. $this->mainCatalog["219"] = "Dr Who Classics";
  112. $this->mainCatalog["113"] = "Dragon Ball";
  113. $this->mainCatalog["135"] = "E-ring";
  114. $this->mainCatalog["26"] = "E.R.";
  115. $this->mainCatalog["161"] = "Earth 2";
  116. $this->mainCatalog["107"] = "Entourage";
  117. $this->mainCatalog["27"] = "Everwood";
  118. $this->mainCatalog["144"] = "Everybody Hates Chris";
  119. $this->mainCatalog["28"] = "Family Guy";
  120. $this->mainCatalog["29"] = "Farscape";
  121. $this->mainCatalog["162"] = "Firefly";
  122. $this->mainCatalog["163"] = "First Wave";
  123. $this->mainCatalog["220"] = "Four Kings";
  124. $this->mainCatalog["164"] = "Frasier";
  125. $this->mainCatalog["93"] = "Free Ride";
  126. $this->mainCatalog["83"] = "Fresh Prince";
  127. $this->mainCatalog["30"] = "Friends";
  128. $this->mainCatalog["234"] = "Full House";
  129. $this->mainCatalog["77"] = "Futurama";
  130. $this->mainCatalog["189"] = "Ghost Whisper";
  131. $this->mainCatalog["31"] = "Gilmore Girls";
  132. $this->mainCatalog["127"] = "Greys Anatomy";
  133. $this->mainCatalog["221"] = "Heist";
  134. $this->mainCatalog["96"] = "Hells Kitchen";
  135. $this->mainCatalog["165"] = "Hex";
  136. $this->mainCatalog["46"] = "Hogans Heroes";
  137. $this->mainCatalog["92"] = "House";
  138. $this->mainCatalog["190"] = "How I Met Your Mother";
  139. $this->mainCatalog["222"] = "How its Made";
  140. $this->mainCatalog["3"] = "Howard Stern";
  141. $this->mainCatalog["235"] = "In Justice";
  142. $this->mainCatalog["32"] = "In Living Color";
  143. $this->mainCatalog["36"] = "Invasion";
  144. $this->mainCatalog["39"] = "Invisible Man";
  145. $this->mainCatalog["33"] = "Iron Chef";
  146. $this->mainCatalog["147"] = "JAG";
  147. $this->mainCatalog["40"] = "Jake 2.0";
  148. $this->mainCatalog["72"] = "Joey";
  149. $this->mainCatalog["69"] = "Killer Instinct";
  150. $this->mainCatalog["35"] = "King of Queens";
  151. $this->mainCatalog["34"] = "King of the Hill";
  152. $this->mainCatalog["117"] = "Las Vegas";
  153. $this->mainCatalog["37"] = "Law and Order";
  154. $this->mainCatalog["223"] = "Law and Order CI";
  155. $this->mainCatalog["224"] = "Law and Order SVU";
  156. $this->mainCatalog["243"] = "Law and Order TBJ";
  157. $this->mainCatalog["194"] = "Little House on the Prairie";
  158. $this->mainCatalog["203"] = "Living with Fran";
  159. $this->mainCatalog["76"] = "Lost";
  160. $this->mainCatalog["38"] = "MacGyver";
  161. $this->mainCatalog["82"] = "Malcolm in the Middle";
  162. $this->mainCatalog["100"] = "Married with Children";
  163. $this->mainCatalog["236"] = "Mayo";
  164. $this->mainCatalog["142"] = "Medium";
  165. $this->mainCatalog["20"] = "Millenium";
  166. $this->mainCatalog["21"] = "Mind of Mencia";
  167. $this->mainCatalog["191"] = "Modern Marvels";
  168. $this->mainCatalog["204"] = "Monk";
  169. $this->mainCatalog["122"] = "My Name Is Earl";
  170. $this->mainCatalog["106"] = "Mythbusters";
  171. $this->mainCatalog["140"] = "NCIS";
  172. $this->mainCatalog["146"] = "Night Stalker";
  173. $this->mainCatalog["119"] = "NipTuck";
  174. $this->mainCatalog["80"] = "Numb3rs";
  175. $this->mainCatalog["237"] = "NYPD Blue";
  176. $this->mainCatalog["118"] = "One Tree Hill";
  177. $this->mainCatalog["41"] = "Outer Limits";
  178. $this->mainCatalog["112"] = "Over There";
  179. $this->mainCatalog["42"] = "OZ";
  180. $this->mainCatalog["25"] = "Penn and Teller Bullshit";
  181. $this->mainCatalog["239"] = "Perfect Strangers";
  182. $this->mainCatalog["43"] = "Pimp My Ride";
  183. $this->mainCatalog["240"] = "Pinks";
  184. $this->mainCatalog["241"] = "Popular";
  185. $this->mainCatalog["114"] = "Prison Break";
  186. $this->mainCatalog["192"] = "Profiler";
  187. $this->mainCatalog["74"] = "Punkd";
  188. $this->mainCatalog["44"] = "Quantum Leap";
  189. $this->mainCatalog["18"] = "Real Time with Bill Maher";
  190. $this->mainCatalog["78"] = "Red Dwarf";
  191. $this->mainCatalog["244"] = "Regenesis";
  192. $this->mainCatalog["205"] = "livingwithfran.gif";
  193. $this->mainCatalog["98"] = "Rescue Me";
  194. $this->mainCatalog["17"] = "Reunion";
  195. $this->mainCatalog["79"] = "Robot Chicken";
  196. $this->mainCatalog["115"] = "Rome";
  197. $this->mainCatalog["45"] = "Roswell";
  198. $this->mainCatalog["193"] = "Saturday Night Live";
  199. $this->mainCatalog["47"] = "Scrubs";
  200. $this->mainCatalog["16"] = "Sealab 2021";
  201. $this->mainCatalog["15"] = "Seaquest";
  202. $this->mainCatalog["48"] = "Seinfeld";
  203. $this->mainCatalog["49"] = "Sex and the City";
  204. $this->mainCatalog["51"] = "Simpsons";
  205. $this->mainCatalog["50"] = "Six Feet Under";
  206. $this->mainCatalog["52"] = "Sliders";
  207. $this->mainCatalog["53"] = "Smallville";
  208. $this->mainCatalog["54"] = "Sopranos";
  209. $this->mainCatalog["55"] = "South Park";
  210. $this->mainCatalog["14"] = "Space 1999";
  211. $this->mainCatalog["185"] = "Space Above and Beyond";
  212. $this->mainCatalog["123"] = "Space Ghost";
  213. $this->mainCatalog["120"] = "Spooks";
  214. $this->mainCatalog["13"] = "Star Hunter";
  215. $this->mainCatalog["58"] = "Star Trek Deep Space Nine";
  216. $this->mainCatalog["56"] = "Star Trek Enterprise";
  217. $this->mainCatalog["60"] = "Star Trek Original Series";
  218. $this->mainCatalog["59"] = "Star Trek The Next Generation";
  219. $this->mainCatalog["57"] = "Star Trek Voyager";
  220. $this->mainCatalog["61"] = "Stargate Atlantis";
  221. $this->mainCatalog["7"] = "Stargate SG-1";
  222. $this->mainCatalog["11"] = "Stella";
  223. $this->mainCatalog["126"] = "Supernatural";
  224. $this->mainCatalog["133"] = "Surface";
  225. $this->mainCatalog["141"] = "Survivor";
  226. $this->mainCatalog["91"] = "Tales from the Crypt";
  227. $this->mainCatalog["62"] = "Tech TV";
  228. $this->mainCatalog["63"] = "That 70s Show";
  229. $this->mainCatalog["149"] = "The Apprentice";
  230. $this->mainCatalog["73"] = "Daily show";
  231. $this->mainCatalog["97"] = "The Inside";
  232. $this->mainCatalog["143"] = "the L word";
  233. $this->mainCatalog["64"] = "The O.C.";
  234. $this->mainCatalog["206"] = "The Office";
  235. $this->mainCatalog["65"] = "The Shield";
  236. $this->mainCatalog["66"] = "The Simple Life";
  237. $this->mainCatalog["226"] = "The Unit";
  238. $this->mainCatalog["67"] = "The West Wing";
  239. $this->mainCatalog["186"] = "The Wire";
  240. $this->mainCatalog["227"] = "Thief";
  241. $this->mainCatalog["148"] = "Third Watch";
  242. $this->mainCatalog["125"] = "Threshold";
  243. $this->mainCatalog["10"] = "Tonite Show";
  244. $this->mainCatalog["207"] = "TopGear";
  245. $this->mainCatalog["8"] = "Trailer Park Boys";
  246. $this->mainCatalog["94"] = "Tripping the Rift";
  247. $this->mainCatalog["4"] = "Tru Calling";
  248. $this->mainCatalog["213"] = "Twilight Zone";
  249. $this->mainCatalog["208"] = "Two and a half men";
  250. $this->mainCatalog["129"] = "Veronica Mars";
  251. $this->mainCatalog["89"] = "Viva La Bam";
  252. $this->mainCatalog["124"] = "Voltron";
  253. $this->mainCatalog["136"] = "Wanted";
  254. $this->mainCatalog["229"] = "War at Home";
  255. $this->mainCatalog["111"] = "Weeds";
  256. $this->mainCatalog["2"] = "Whose Line is it Anyway";
  257. $this->mainCatalog["242"] = "Wildfire";
  258. $this->mainCatalog["150"] = "Will and Grace";
  259. $this->mainCatalog["145"] = "Without a Trace";
  260. $this->mainCatalog["68"] = "X-Files";
  261. }
  262. //----------------------------------------------------------------
  263. // Function to Get Sub Categories
  264. /* function getSubCategories($mainGenre)
  265. {
  266. return $output;
  267. }*/
  268. //----------------------------------------------------------------
  269. // Function to Make the Request (overriding base)
  270. function makeRequest($request)
  271. {
  272. return parent::makeRequest($request, false);
  273. }
  274. //----------------------------------------------------------------
  275. // Function to get Latest..
  276. function getLatest()
  277. {
  278. $cat = tfb_getRequestVar('mainGenre');
  279. if (empty($cat)) $cat = tfb_getRequestVar('cat');
  280. $request = "/browse.php";
  281. if(!empty($cat))
  282. {
  283. if(strpos($request,"?"))
  284. {
  285. $request .= "&cat=".$cat;
  286. }
  287. else
  288. {
  289. $request .= "?cat=".$cat;
  290. }
  291. }
  292. if (!empty($this->pg))
  293. {
  294. if(strpos($request,"?"))
  295. {
  296. $request .= "&page=" . $this->pg;
  297. }
  298. else
  299. {
  300. $request .= "?page=" . $this->pg;
  301. }
  302. }
  303. if ($this->makeRequest($request,true))
  304. {
  305. if (strlen($this->htmlPage) > 0 )
  306. {
  307. return $this->parseResponse();
  308. }
  309. else
  310. {
  311. return 'Unable to Browse at this time.';
  312. }
  313. }
  314. else
  315. {
  316. return $this->msg;
  317. }
  318. }
  319. //----------------------------------------------------------------
  320. // Function to perform Search.
  321. function performSearch($searchTerm)
  322. {
  323. // create the request string.
  324. $searchTerm = str_replace(" ", "+", $searchTerm);
  325. $request = "/browse.php?search=".$searchTerm;
  326. if(!empty($cat))
  327. {
  328. $request .= "&cat=".$cat;
  329. }
  330. $incldead = tfb_getRequestVar('incldead');
  331. if (empty($incldead)) $incldead = "0";
  332. $request .= "&incldead=".$incldead;
  333. if (!empty($this->pg))
  334. {
  335. $request .= "&page=" . $this->pg;
  336. }
  337. if ($this->makeRequest($request,true))
  338. {
  339. return $this->parseResponse();
  340. }
  341. else
  342. {
  343. return $this->msg;
  344. }
  345. }
  346. //----------------------------------------------------------------
  347. // Override the base to show custom table header.
  348. // Function to setup the table header
  349. function tableHeader()
  350. {
  351. $output = "<table width=\"100%\" cellpadding=3 cellspacing=0 border=0>";
  352. $output .= "<br>\n";
  353. $output .= "<tr bgcolor=\"".$this->cfg["bgLight"]."\">";
  354. if ($needWait)
  355. {
  356. $output .= " <td colspan=8 align=center>";
  357. }
  358. else
  359. {
  360. $output .= " <td colspan=7 align=center>";
  361. }
  362. if (is_integer(strpos($this->htmlPage,"Welcome back, ")))
  363. {
  364. $userinfo = substr($this->htmlPage,strpos($this->htmlPage,"Welcome back, ")+strlen("Welcome back, "));
  365. $userinfo = substr($userinfo,strpos($userinfo,"<br/>")+strlen("<br/>"));
  366. $userinfo = substr($userinfo,0,strpos($userinfo,"</span>"));
  367. //$userinfo = substr($userinfo,strpos($userinfo,"<br>")+strlen("<br>"));
  368. //$userinfo = str_replace("<font class=\"font_10px\">","",$userinfo);
  369. //$userinfo = str_replace("</font>","",$userinfo);
  370. //$userinfo = str_replace("<br>","",$userinfo);
  371. //$output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">";
  372. $output .= $userinfo;
  373. }
  374. $output .= "</td></tr>";
  375. $output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">";
  376. $output .= " <td>&nbsp;</td>";
  377. $output .= " <td><strong>Torrent Name</strong> &nbsp;(";
  378. $tmpURI = str_replace(array("?hideSeedless=yes","&hideSeedless=yes","?hideSeedless=no","&hideSeedless=no"),"",$_SERVER["REQUEST_URI"]);
  379. // Check to see if Question mark is there.
  380. if (strpos($tmpURI,'?'))
  381. {
  382. $tmpURI .= "&";
  383. }
  384. else
  385. {
  386. $tmpURI .= "?";
  387. }
  388. if($this->hideSeedless == "yes")
  389. {
  390. $output .= "<a href=\"". $tmpURI . "hideSeedless=no\">Show Seedless</a>";
  391. }
  392. else
  393. {
  394. $output .= "<a href=\"". $tmpURI . "hideSeedless=yes\">Hide Seedless</a>";
  395. }
  396. $output .= ")</td>";
  397. $output .= " <td><strong>Category</strong></td>";
  398. $output .= " <td align=center><strong>&nbsp;&nbsp;Size</strong></td>";
  399. $output .= " <td><strong>Seeds</strong></td>";
  400. $output .= " <td><strong>Peers</strong></td>";
  401. $output .= " <td><strong>Snatched</strong></td>";
  402. $output .= "</tr>\n";
  403. return $output;
  404. }
  405. //----------------------------------------------------------------
  406. // Function to parse the response.
  407. function parseResponse($latest = true)
  408. {
  409. $thing = $this->htmlPage;
  410. if(strpos($thing,"Not logged in!") > 0)
  411. {
  412. $tmpStr = substr($thing,strpos($thing,"takelogin"));
  413. $tmpStr = substr($tmpStr,strpos($tmpStr, ">")+1);
  414. $tmpStr2 = "<form method=\"post\" action=\"http://".$this->mainURL."/takelogin.php\">";
  415. $tmpStr = substr($tmpStr,0,strpos($tmpStr,"</form>")+strlen("</form>"));
  416. $output = $tmpStr2.str_replace("src=\"","src=\"http://".$this->mainURL."/",$tmpStr)."</table>";
  417. }
  418. else
  419. {
  420. $output = $this->tableHeader();
  421. if(strpos($thing,"Error:") > 0)
  422. {
  423. $tmpStr = substr($thing,strpos($thing,"Error:")+strlen("Error:"));
  424. $tmpStr = substr($tmpStr,0,strpos($tmpStr,"</p>"));
  425. $this->msg = strip_tags($tmpStr);
  426. return $output . "<center>".$this->msg."</center><br>";
  427. }
  428. // We got a response so display it.
  429. // Chop the front end off.
  430. $thing = substr($thing,strpos($thing,"Leechers</a></td>"));
  431. $thing = substr($thing,strpos($thing,"<tr>")+strlen("<tr>"));
  432. //$tmpList = substr($thing,0,strpos($thing,"</table>"));
  433. // ok so now we have the listing.
  434. $tmpListArr = explode("</tr>",$thing);
  435. $bg = $this->cfg["bgLight"];
  436. //var_export($tmpListArr);
  437. foreach($tmpListArr as $key =>$value)
  438. {
  439. $buildLine = true;
  440. if (strpos($value,"id="))
  441. {
  442. $ts = new BitMeTv($value);
  443. if (!empty($ts->torrentFile) && $buildLine) {
  444. $output .= trim($ts->BuildOutput($bg,$this->searchURL()));
  445. // ok switch colors.
  446. if ($bg == $this->cfg["bgLight"])
  447. {
  448. $bg = $this->cfg["bgDark"];
  449. }
  450. else
  451. {
  452. $bg = $this->cfg["bgLight"];
  453. }
  454. }
  455. }
  456. }
  457. // set thing to end of this table.
  458. $thing = substr($thing,strpos($thing,"</table>"));
  459. $output .= "</table>";
  460. // is there paging at the bottom?
  461. if (strpos($thing, "page=") != false)
  462. {
  463. // Yes, then lets grab it and display it! ;)
  464. $pages = substr($thing,strpos($thing,"<p"));
  465. $pages = substr($pages,strpos($pages,">"));
  466. $pages = substr($pages,0,strpos($pages,"</p>"));
  467. $pages = str_replace("&nbsp; ",'',$pages);
  468. $tmpPageArr = explode("</a>",$pages);
  469. array_pop($tmpPageArr);
  470. $pagesout = '';
  471. foreach($tmpPageArr as $key => $value)
  472. {
  473. $value .= "</a> &nbsp;";
  474. $tmpVal = substr($value,strpos($value,"browse.php?"),strpos($value,">")-1);
  475. $pgNum = substr($tmpVal,strpos($tmpVal,"page=")+strlen("page="));
  476. $pagesout .= str_replace($tmpVal,"XXXURLXXX".$pgNum,$value);
  477. }
  478. $cat = tfb_getRequestVar('mainGenre');
  479. if(strpos($this->curRequest,"LATEST"))
  480. {
  481. if (!empty($cat))
  482. {
  483. $pages = str_replace("XXXURLXXX",$this->searchURL()."&LATEST=1&cat=".$cat."&pg=",$pagesout);
  484. }
  485. else
  486. {
  487. $pages = str_replace("XXXURLXXX",$this->searchURL()."&LATEST=1&pg=",$pagesout);
  488. }
  489. }
  490. else
  491. {
  492. if(!empty($cat))
  493. {
  494. $pages = str_replace("XXXURLXXX",$this->searchURL()."&searchterm=".$_REQUEST["searchterm"]."&cat=".$cat."&pg=",$pagesout);
  495. }
  496. else
  497. {
  498. $pages = str_replace("XXXURLXXX",$this->searchURL()."&searchterm=".$_REQUEST["searchterm"]."&pg=",$pagesout);
  499. }
  500. }
  501. // $pages = strip_tags($pages,"<a><b>");
  502. $output .= "<div align=center>".substr($pages,1)."</div>";
  503. }
  504. }
  505. return $output;
  506. }
  507. }
  508. // This is a worker class that takes in a row in a table and parses it.
  509. class BitMeTv
  510. {
  511. var $torrentName = "";
  512. var $torrentDisplayName = "";
  513. var $torrentFile = "";
  514. var $torrentSize = "";
  515. var $torrentStatus = "";
  516. var $MainId = "";
  517. var $MainCategory = "";
  518. var $fileCount = "";
  519. var $Seeds = "";
  520. var $Peers = "";
  521. var $needsWait = false;
  522. var $waitTime = "";
  523. var $Data = "";
  524. var $torrentRating = "";
  525. function BitMeTv( $htmlLine )
  526. {
  527. if (strlen($htmlLine) > 0)
  528. {
  529. $this->Data = $htmlLine;
  530. // Cleanup any bugs in the HTML
  531. $htmlLine = preg_replace("/</td>\n</td>/i",'</td>',$htmlLine);
  532. // Chunck up the row into columns.
  533. $tmpListArr = explode("<td ",$htmlLine);
  534. $tmpStr = substr($tmpListArr["1"],strpos($tmpListArr["1"],"alt=\"")+strlen("alt=\"")); // MainCategory
  535. $this->MainCategory = substr($tmpStr,0,strpos($tmpStr,"\""));
  536. $tmpStr = substr($tmpListArr["1"],strpos($tmpListArr["1"],"cat=")+strlen("cat=")); // Main Id
  537. $this->MainId = substr($tmpStr,0,strpos($tmpStr,"\""));
  538. //$this->torrentName = $this->cleanLine("<td ".$tmpListArr["2"]."</td>"); // TorrentName
  539. $this->torrentName = substr($tmpListArr["2"],strpos($tmpListArr["2"],"<b>")+strlen("<b>"),strpos($tmpListArr["2"],"</b>"));
  540. $tmpStr = substr($tmpListArr["3"],strpos($tmpListArr["3"],"href=\"download.php")+strlen("href=\""));
  541. $this->torrentFile = "http://www.bitmetv.org/".substr($tmpStr,0,strpos($tmpStr,"\""));
  542. //$tmpStr = substr($tmpListArr["2"],strpos($tmpListArr["2"],"id=")+strlen("id=")); // File Id
  543. //$tmpStr = substr($tmpStr,0,strpos($tmpStr,"&"));
  544. //$this->torrentFile = "http://oink.me.uk/downloadpk/".$tmpStr."/".str_replace(" ","_",$this->torrentName).".torrent";
  545. $this->fileCount = $this->cleanLine("<td ".$tmpListArr["4"]."</td>"); // File Count
  546. $this->torrentSize = $this->cleanLine("<td ".$tmpListArr["8"]."</td>"); // Size of File
  547. $this->torrentStatus = $this->cleanLine(str_replace("<br>"," ","<td ".$tmpListArr["9"]."</td>")); // Snatched
  548. $this->Seeds = $this->cleanLine("<td ".$tmpListArr["10"]."</td>"); // Seeds
  549. $this->Peers = $this->cleanLine("<td ".$tmpListArr["11"]."</td>"); // Leech
  550. $this->torrentDisplayName = $this->torrentName;
  551. if(strlen($this->torrentDisplayName) > 50)
  552. {
  553. $this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."...";
  554. }
  555. }
  556. }
  557. function cleanLine($stringIn,$tags='')
  558. {
  559. if(empty($tags))
  560. return trim(str_replace(array("&nbsp;","&nbsp")," ",strip_tags($stringIn)));
  561. else
  562. return trim(str_replace(array("&nbsp;","&nbsp")," ",strip_tags($stringIn,$tags)));
  563. }
  564. //----------------------------------------------------------------
  565. // Function to build output for the table.
  566. function BuildOutput($bg, $searchURL = '')
  567. {
  568. $output = "<tr>\n";
  569. $output .= " <td width=16 bgcolor=\"".$bg."\"><a href=\"dispatcher.php?action=urlUpload&type=torrent&url=".$this->torrentFile."\"><img src=\"".getImagesPath()."download_owner.gif\" width=\"16\" height=\"16\" title=\"".$this->torrentName."\" border=0></a></td>\n";
  570. $output .= " <td bgcolor=\"".$bg."\"><a href=\"dispatcher.php?action=urlUpload&type=torrent&url=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a></td>\n";
  571. if (strlen($this->MainCategory) > 1){
  572. $genre = "<a href=\"".$searchURL."&mainGenre=".$this->MainId."\">".$this->MainCategory."</a>";
  573. }else{
  574. $genre = "";
  575. }
  576. $output .= " <td bgcolor=\"".$bg."\">". $genre ."</td>\n";
  577. $output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n";
  578. $output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n";
  579. $output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n";
  580. $output .= " <td bgcolor=\"".$bg."\" align=center>".$this->torrentStatus."</td>\n";
  581. $output .= "</tr>\n";
  582. return $output;
  583. }
  584. }
  585. ?>