1
0

DemonoidEngine.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. <?php
  2. /* $Id: DemonoidEngine.php 2506 2007-02-04 15:12:30Z 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. /*
  22. v 1.06 - Dec 12. 06 - Change path on main pages.
  23. v 1.05 - May 20. 06 - Change to paging URL, addtion of user stats as per Qromes Request (should now appear above column headers)
  24. v 1.04 - Apr 26. 06 - Fixed filtering lists - Possible bug in admin.php (line 1997 - option value [NO FILTER] needs setting to -1 instead of "")
  25. v 1.03 - Apr 21, 06 - Modified first row on table to reflect correct date
  26. v 1.02 - Apr 18, 06 - Added Update URL
  27. v 1.01 - Apr 17, 06 - bug in filtering.
  28. */
  29. class SearchEngine extends SearchEngineBase
  30. {
  31. function SearchEngine($cfg)
  32. {
  33. $this->mainURL = "www.demonoid.com";
  34. $this->altURL = "www.demonoid.com";
  35. $this->mainTitle = "Demonoid";
  36. $this->engineName = "Demonoid";
  37. $this->author = "moldavite";
  38. $this->version = "1.06-tfb";
  39. $this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,1210.0.html";
  40. $this->Initialize($cfg);
  41. }
  42. function populateMainCategories()
  43. {
  44. $this->mainCatalog["0"] = "(all types)";
  45. $this->mainCatalog["9"] = "Anime";
  46. $this->mainCatalog["5"] = "Applications";
  47. $this->mainCatalog["17"] = "Audio Books";
  48. $this->mainCatalog["11"] = "Books";
  49. $this->mainCatalog["10"] = "Comics";
  50. $this->mainCatalog["4"] = "Games";
  51. $this->mainCatalog["6"] = "Misc";
  52. $this->mainCatalog["1"] = "Movies";
  53. $this->mainCatalog["2"] = "Music";
  54. $this->mainCatalog["13"] = "Music Videos";
  55. $this->mainCatalog["8"] = "Pictures";
  56. $this->mainCatalog["3"] = "TV";
  57. }
  58. //----------------------------------------------------------------
  59. // Function to Get Sub Categories
  60. function getSubCategories($mainGenre)
  61. {
  62. $output = array();
  63. switch ($mainGenre)
  64. {
  65. case "1" :
  66. $output["1:ALL"] = "All";
  67. $output["1:6"] = "Action";
  68. $output["1:7"] = "Adventure";
  69. $output["1:8"] = "Animation";
  70. $output["1:9"] = "Biography";
  71. $output["1:10"] = "Comedy";
  72. $output["1:180"] = "Concerts";
  73. $output["1:181"] = "Crime";
  74. $output["1:11"] = "Documentary";
  75. $output["1:12"] = "Drama";
  76. $output["1:13"] = "Family";
  77. $output["1:14"] = "Fantasy";
  78. $output["1:15"] = "Film-Noir";
  79. $output["1:17"] = "Horror";
  80. $output["1:18"] = "Musical";
  81. $output["1:19"] = "Mystery";
  82. $output["1:65"] = "Other";
  83. $output["1:20"] = "Romance";
  84. $output["1:21"] = "Sci-Fi";
  85. $output["1:22"] = "Short film";
  86. $output["1:23"] = "Sports";
  87. $output["1:24"] = "Thriller";
  88. $output["1:182"] = "Trailers";
  89. $output["1:25"] = "War";
  90. $output["1:26"] = "Western";
  91. break;
  92. case "2" :
  93. $output["2:All"] = "All";
  94. $output["2:183"] = "Alternative";
  95. $output["2:34"] = "Blues";
  96. $output["2:185"] = "Christian";
  97. $output["2:27"] = "Classical";
  98. $output["2:186"] = "Comedy";
  99. $output["2:44"] = "Contemporary African";
  100. $output["2:36"] = "Country";
  101. $output["2:39"] = "Dance / Disco";
  102. $output["2:37"] = "Electro / Techno";
  103. $output["2:28"] = "Gospel";
  104. $output["2:43"] = "Hip-Hop / Rap";
  105. $output["2:38"] = "Industrial";
  106. $output["2:184"] = "J-Pop";
  107. $output["2:29"] = "Jazz";
  108. $output["2:30"] = "Latin American";
  109. $output["2:40"] = "Melodic";
  110. $output["2:35"] = "Metal";
  111. $output["2:63"] = "Other";
  112. $output["2:31"] = "Pop";
  113. $output["2:42"] = "Punk";
  114. $output["2:41"] = "Reggae";
  115. $output["2:33"] = "Rhythm and blues";
  116. $output["2:32"] = "Rock";
  117. $output["2:188"] = "Soul";
  118. $output["2:190"] = "Soundtrack";
  119. $output["2:191"] = "Trance";
  120. break;
  121. case "3" :
  122. $output["3:All"] = "All";
  123. $output["3:192"] = "Action";
  124. $output["3:193"] = "Adventure";
  125. $output["3:194"] = "Animation";
  126. $output["3:195"] = "Biography";
  127. $output["3:196"] = "Comedy";
  128. $output["3:213"] = "Concerts";
  129. $output["3:214"] = "Crime";
  130. $output["3:197"] = "Documentary";
  131. $output["3:198"] = "Drama";
  132. $output["3:199"] = "Family";
  133. $output["3:200"] = "Fantasy";
  134. $output["3:201"] = "Film-Noir";
  135. $output["3:203"] = "Horror";
  136. $output["3:202"] = "Musical";
  137. $output["3:204"] = "Mystery";
  138. $output["3:212"] = "Other";
  139. $output["3:205"] = "Romance";
  140. $output["3:206"] = "Sci-Fi";
  141. $output["3:207"] = "Short film";
  142. $output["3:208"] = "Sports";
  143. $output["3:259"] = "Talk show";
  144. $output["3:209"] = "Thriller";
  145. $output["3:215"] = "Trailers";
  146. $output["3:210"] = "War";
  147. $output["3:211"] = "Western";
  148. break;
  149. case "4" :
  150. $output["4:All"] = "All";
  151. $output["4:177"] = "DOS";
  152. $output["4:176"] = "Dreamcast";
  153. $output["4:178"] = "Emulators";
  154. $output["4:167"] = "GameBoy";
  155. $output["4:175"] = "GameCube";
  156. $output["4:162"] = "Linux";
  157. $output["4:163"] = "Macintosh";
  158. $output["4:168"] = "Mobile phone";
  159. $output["4:261"] = "Nintendo DS";
  160. $output["4:164"] = "Palm";
  161. $output["4:170"] = "Playstation 1";
  162. $output["4:171"] = "Playstation 2";
  163. $output["4:172"] = "Playstation 3";
  164. $output["4:165"] = "PocketPC";
  165. $output["4:169"] = "PSP";
  166. $output["4:166"] = "Windows";
  167. $output["4:173"] = "XBox";
  168. $output["4:174"] = "XBox 360";
  169. break;
  170. case "5" :
  171. $output["5:All"] = "All";
  172. $output["5:2"] = "Linux";
  173. $output["5:3"] = "Macintosh";
  174. $output["5:118"] = "Mobile phone";
  175. $output["5:5"] = "Palm";
  176. $output["5:4"] = "PocketPC";
  177. $output["5:1"] = "Windows";
  178. break;
  179. case "6" :
  180. $output["6:All"] = "All";
  181. break;
  182. case "8" :
  183. $output["8:All"] = "All";
  184. $output["8:66"] = "Art";
  185. $output["8:67"] = "Commercial";
  186. $output["8:69"] = "Glamour";
  187. $output["8:73"] = "Other";
  188. $output["8:68"] = "Photojournalism";
  189. $output["8:70"] = "Snapshots";
  190. $output["8:71"] = "Sports";
  191. $output["8:72"] = "Wildlife";
  192. break;
  193. case "9" :
  194. $output["9:All"] = "All";
  195. $output["9:111"] = "Action";
  196. $output["9:220"] = "Adventure";
  197. $output["9:112"] = "Comedy";
  198. $output["9:113"] = "Drama";
  199. $output["9:114"] = "Fantasy";
  200. $output["9:115"] = "Horror";
  201. $output["9:221"] = "Other";
  202. $output["9:117"] = "Romance";
  203. $output["9:116"] = "Sci-Fi";
  204. break;
  205. case "10" :
  206. $output["10:All"] = "All";
  207. $output["10:159"] = "Action / Adventure";
  208. $output["10:227"] = "Crime";
  209. $output["10:160"] = "Drama";
  210. $output["10:223"] = "Fantasy";
  211. $output["10:228"] = "Historical fiction";
  212. $output["10:224"] = "Horror";
  213. $output["10:161"] = "Illustrated novel";
  214. $output["10:229"] = "Other";
  215. $output["10:226"] = "Real-Life";
  216. $output["10:225"] = "Sci-Fi";
  217. $output["10:222"] = "Super Hero";
  218. break;
  219. case "11" :
  220. $output["11:All"] = "All";
  221. $output["11:119"] = "Action";
  222. $output["11:120"] = "Adventure";
  223. $output["11:122"] = "Childrens";
  224. $output["11:137"] = "Computers";
  225. $output["11:123"] = "Contemporary";
  226. $output["11:124"] = "Fantasy";
  227. $output["11:125"] = "General";
  228. $output["11:126"] = "Horror";
  229. $output["11:127"] = "Humor";
  230. $output["11:128"] = "Literary";
  231. $output["11:129"] = "Mainstream";
  232. $output["11:138"] = "Misc. Educational";
  233. $output["11:130"] = "Mystery";
  234. $output["11:230"] = "Other";
  235. $output["11:131"] = "Paranormal";
  236. $output["11:132"] = "Romance";
  237. $output["11:260"] = "RPG";
  238. $output["11:133"] = "Sci-Fi";
  239. $output["11:121"] = "Self-help";
  240. $output["11:134"] = "Suspense";
  241. $output["11:135"] = "Thriller";
  242. $output["11:136"] = "Western";
  243. break;
  244. case "13" :
  245. $output["13:All"] = "All";
  246. $output["13:251"] = "Alternative";
  247. $output["13:239"] = "Blues";
  248. $output["13:253"] = "Christian";
  249. $output["13:232"] = "Classical";
  250. $output["13:254"] = "Comedy";
  251. $output["13:249"] = "Contemporary African";
  252. $output["13:241"] = "Country";
  253. $output["13:244"] = "Dance / Disco";
  254. $output["13:242"] = "Electro / Techno";
  255. $output["13:233"] = "Gospel";
  256. $output["13:248"] = "Hip-Hop / Rap";
  257. $output["13:243"] = "Industrial";
  258. $output["13:252"] = "J-Pop";
  259. $output["13:234"] = "Jazz";
  260. $output["13:235"] = "Latin American";
  261. $output["13:245"] = "Melodic";
  262. $output["13:240"] = "Metal";
  263. $output["13:250"] = "Other";
  264. $output["13:236"] = "Pop";
  265. $output["13:247"] = "Punk";
  266. $output["13:246"] = "Reggae";
  267. $output["13:256"] = "Reggae";
  268. $output["13:238"] = "Rhythm and blues";
  269. $output["13:237"] = "Rock";
  270. $output["13:255"] = "Soul";
  271. $output["13:257"] = "Soundtrack";
  272. $output["13:258"] = "Trance";
  273. break;
  274. case "17" :
  275. $output["17:All"] = "All";
  276. $output["17:140"] = "Action";
  277. $output["17:139"] = "Adventure";
  278. $output["17:142"] = "Childrens";
  279. $output["17:157"] = "Computers";
  280. $output["17:143"] = "Contemporary";
  281. $output["17:144"] = "Fantasy";
  282. $output["17:145"] = "General";
  283. $output["17:146"] = "Horror";
  284. $output["17:147"] = "Humor";
  285. $output["17:148"] = "Literary";
  286. $output["17:149"] = "Mainstream";
  287. $output["17:158"] = "Misc. Educational";
  288. $output["17:150"] = "Mystery";
  289. $output["17:231"] = "Other";
  290. $output["17:151"] = "Paranormal";
  291. $output["17:152"] = "Romance";
  292. $output["17:153"] = "Sci-Fi";
  293. $output["17:141"] = "Self-help";
  294. $output["17:154"] = "Suspense";
  295. $output["17:155"] = "Thriller";
  296. $output["17:156"] = "Western";
  297. break;
  298. }
  299. return $output;
  300. }
  301. //----------------------------------------------------------------
  302. // Function to Make the Request (overriding base)
  303. function makeRequest($request)
  304. {
  305. return parent::makeRequest($request, false);
  306. }
  307. //----------------------------------------------------------------
  308. // Function to get Latest..
  309. function getLatest()
  310. {
  311. $request = '/files/';
  312. if (array_key_exists("mainGenre",$_REQUEST) && array_key_exists("subGenre",$_REQUEST))
  313. {
  314. $request = "/files/?category=".$_REQUEST["mainGenre"]."&subcategory=".$_REQUEST["subGenre"]."&language=0&seeded=0&external=2&query=&uid=0";
  315. }
  316. elseif (array_key_exists("subGenre",$_REQUEST))
  317. {
  318. $splitted = explode(":", $_REQUEST['subGenre']);
  319. $request = "/files/?category=".$splitted[0]."&subcategory=".$splitted[1]."&language=0&seeded=0&external=2&query=&uid=0";
  320. }
  321. else
  322. {
  323. $request = "/files/";
  324. }
  325. if (!empty($this->pg))
  326. {
  327. if(strpos($request,"?"))
  328. {
  329. $request .= "&page=" . $this->pg;
  330. }
  331. else
  332. {
  333. $request .= "?page=" . $this->pg;
  334. }
  335. }
  336. if ($this->makeRequest($request))
  337. {
  338. return $this->parseResponse();
  339. }
  340. else
  341. {
  342. return $this->msg;
  343. }
  344. }
  345. //----------------------------------------------------------------
  346. // Function to perform Search.
  347. function performSearch($searchTerm)
  348. {
  349. if (array_key_exists("mainGenre",$_REQUEST) && array_key_exists("subGenre",$_REQUEST))
  350. {
  351. $request = "/files/?category=".$_REQUEST['mainGenre']."&subcategory=".$_REQUEST["subGenre"]."&language=0&seeded=0&external=2&query=&uid=0";
  352. }
  353. // elseif (array_key_exists("mainGenre",$_REQUEST))
  354. // {
  355. // $request = "/torrents/?category=".$_REQUEST["mainGenre"]."&subcategory=All&language=0&seeded=0&external=2&query=&uid=0";
  356. // }
  357. else
  358. {
  359. $request = "/files/?query=".$searchTerm;
  360. }
  361. if(strlen($searchTerm) > 0)
  362. {
  363. $searchTerm = str_replace(" ", "+", $searchTerm);
  364. }
  365. if (!empty($this->pg))
  366. {
  367. $request .= "&page=" . $this->pg;
  368. }
  369. if ($this->makeRequest($request))
  370. {
  371. return $this->parseResponse();
  372. }
  373. else
  374. {
  375. return $this->msg;
  376. }
  377. }
  378. //----------------------------------------------------------------
  379. // Override the base to show custom table header.
  380. // Function to setup the table header
  381. function tableHeader()
  382. {
  383. $output = "<table width=\"100%\" cellpadding=3 cellspacing=0 border=0>";
  384. $output .= "<br>\n";
  385. //v1.05 Update Starts here
  386. if (is_integer(strpos($this->htmlPage,"class=user_box>")))
  387. {
  388. $userinfo = substr($this->htmlPage,strpos($this->htmlPage,"<td class=user_box>")+strlen("<td class=user_box>"));
  389. $userinfo = substr($userinfo,0,strpos($userinfo,"</td>"));
  390. $userinfo = substr($userinfo,strpos($userinfo,"<br>")+strlen("<br>"));
  391. $userinfo = str_replace("<font class=\"font_10px\">","",$userinfo);
  392. $userinfo = str_replace("</font>","",$userinfo);
  393. $userinfo = str_replace("<br>","",$userinfo);
  394. $output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">";
  395. $output .= "<td colspan=6 align=center><b>".$userinfo."</td></tr>";
  396. }
  397. //v1.05 Update Ends here
  398. $output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">";
  399. $output .= " <td>&nbsp;</td>";
  400. $output .= " <td><strong>Torrent Name</strong> &nbsp;(";
  401. $tmpURI = str_replace(array("?hideSeedless=yes","&hideSeedless=yes","?hideSeedless=no","&hideSeedless=no"),"",$_SERVER["REQUEST_URI"]);
  402. //Check to see if Question mark is there.
  403. if (strpos($tmpURI,'?'))
  404. {
  405. $tmpURI .= "&";
  406. }
  407. else
  408. {
  409. $tmpURI .= "?";
  410. }
  411. if($this->hideSeedless == "yes")
  412. {
  413. $output .= "<a href=\"". $tmpURI . "hideSeedless=no\">Show Seedless</a>";
  414. }
  415. else
  416. {
  417. $output .= "<a href=\"". $tmpURI . "hideSeedless=yes\">Hide Seedless</a>";
  418. }
  419. $output .= ")</td>";
  420. $output .= " <td><strong>Category</strong></td>";
  421. $output .= " <td align=center><strong>&nbsp;&nbsp;Size</strong></td>";
  422. $output .= " <td><strong>Seeds</strong></td>";
  423. $output .= " <td><strong>Peers</strong></td>";
  424. $output .= "</tr>\n";
  425. return $output;
  426. }
  427. //----------------------------------------------------------------
  428. // Function to parse the response.
  429. function parseResponse()
  430. {
  431. $output = $this->tableHeader();
  432. if (is_integer(strpos($this->htmlPage,"class=\"added_today\">")))
  433. {
  434. $dateheader = substr($this->htmlPage,strpos($this->htmlPage,"<td colspan=\"10\" class=\"added_today\">")+strlen("<td colspan=\"10\" class=\"added_today\">"));
  435. $dateheader = substr($dateheader,0,strpos($dateheader,"</td>"));
  436. $output .= "<tr bgcolor=\"\"> <td colspan=\"6\" align=center>".$dateheader."</td></tr>\n";
  437. }
  438. $thing = $this->htmlPage;
  439. $thing = str_replace("<a href=\"","<a href=\"http://www.demonoid.com",$thing);
  440. $thing = str_replace("<img src=\"","<img src=\"http://www.demonoid.com",$thing);
  441. // We got a response so display it.
  442. // Chop the front end off.
  443. while (is_integer(strpos($thing,"class=\"added")))
  444. {
  445. $thing = substr($thing,strpos($thing,"class=\"added"));
  446. $thing = str_replace("<td colspan=\"10\" class=\"added_today\">","<td colspan=\"10\" class=\"today\">",$thing);
  447. $thing = substr($thing,strpos($thing,"<tr>"));
  448. $tmplist = substr($thing,0,strpos($thing,"<tr><td colspan=\"10\" align=\"center\""));
  449. // ok so now we have the listing.
  450. $tmpListArr = explode("</tr><tr>",$tmplist);
  451. $bg = $this->cfg["bgLight"];
  452. foreach($tmpListArr as $key =>$value)
  453. {
  454. $buildLine = true;
  455. if (strpos($value,"www.demonoid.com"))
  456. {
  457. $ts = new dmnd($value);
  458. // Determine if we should build this output
  459. if (is_int(array_search($ts->MainId,$this->catFilter)))
  460. {
  461. $buildLine = false;
  462. }
  463. if ($this->hideSeedless == "yes")
  464. {
  465. if($ts->Seeds == "N/A" || $ts->Seeds == "0")
  466. {
  467. $buildLine = false;
  468. }
  469. }
  470. if (!empty($ts->torrentFile) && $buildLine) {
  471. $output .= trim($ts->BuildOutput($bg, $this->searchURL()));
  472. // ok switch colors.
  473. if ($bg == $this->cfg["bgLight"])
  474. {
  475. $bg = $this->cfg["bgDark"];
  476. }
  477. else
  478. {
  479. $bg = $this->cfg["bgLight"];
  480. }
  481. }
  482. }
  483. }
  484. }
  485. $output .= "</table>";
  486. // is there paging at the bottom?
  487. if (strpos($thing, "&page=") != false)
  488. {
  489. // Yes, then lets grab it and display it! ;)
  490. $thing = substr($thing,strpos($thing,"<tr><td colspan")+strlen("<tr><td colspan"));
  491. $thing = substr($thing,strpos($thing,">")+1);
  492. $pages = substr($thing,0,strpos($thing,"</td>"));
  493. if(strpos($this->curRequest,"LATEST"))
  494. {
  495. $pages = str_replace("http://www.demonoid.com/files/?",$this->searchURL()."&LATEST=1&",$pages);
  496. }
  497. else
  498. {
  499. $pages = str_replace("http://www.demonoid.com/files/?",$this->searchURL()."&",$pages);
  500. }
  501. $pages = str_replace("page=","pg=",$pages);
  502. $pages = str_replace("subcategory=","subGenre=",$pages);
  503. $pages = str_replace("category=","mainGenre=",$pages);
  504. $pages = str_replace("&&","&",$pages);
  505. $output .= "<div align=center>".$pages."</div>";
  506. }
  507. return $output;
  508. }
  509. }
  510. // This is a worker class that takes in a row in a table and parses it.
  511. class dmnd
  512. {
  513. var $torrentName = "";
  514. var $torrentDisplayName = "";
  515. var $torrentFile = "";
  516. var $torrentSize = "";
  517. var $torrentStatus = "";
  518. var $CatName = "";
  519. var $CatId = "";
  520. var $MainId = "";
  521. var $MainCategory = "";
  522. var $SubId = "";
  523. var $SubCategory = "";
  524. var $Seeds = "";
  525. var $Peers = "";
  526. var $Data = "";
  527. var $dateAdded = "";
  528. var $dwnldCount = "";
  529. function dmnd( $htmlLine )
  530. {
  531. if (strlen($htmlLine) > 0)
  532. {
  533. $this->Data = $htmlLine;
  534. $tmpListArr = explode("</td>",$htmlLine);
  535. if(count($tmpListArr) >= 13)
  536. {
  537. // Category Id
  538. $tmpStr = "";
  539. $tmpStr = substr($tmpListArr["0"],strpos($tmpListArr["0"],"category=")+strlen("category="));
  540. $this->CatId = substr($tmpStr,0,strpos($tmpStr,"&"));
  541. //Category Name
  542. $tmpStr = "";
  543. $tmpStr = substr($tmpListArr["0"],strpos($tmpListArr["0"],"title=\"")+strlen("title=\""));
  544. $this->CatName = substr($tmpStr,0,strpos($tmpStr,"\""));
  545. //SubCategory ID
  546. $tmpStr = "";
  547. $tmpStr = substr($tmpListArr["2"],strpos($tmpListArr["2"],"subcategory=")+strlen("subcategory="));
  548. $this->SubId = substr($tmpStr,0,strpos($tmpStr,"&"));
  549. //SubCategory Name
  550. $tmpStr = "";
  551. $tmpStr = substr($tmpListArr["2"],strpos($tmpListArr["2"],"subcategory\"")+strlen("subcategory\">"));
  552. $this->SubCategory = substr($tmpStr,0,strpos($tmpStr,"<"));
  553. //validate Subcategory ID
  554. if (!is_numeric($this->SubId)){
  555. $this->SubId = "0";
  556. $this->SubCategory = "All";
  557. }
  558. //Set Category
  559. $this->MainCategory = $this->CatName;
  560. $this->MainId = $this->CatId;
  561. $this->SubId = $this->CatId.":".$this->SubId;
  562. // TorrentName
  563. $this->torrentName = $this->cleanLine($tmpListArr["1"]);
  564. // Download Link
  565. $tmpStr = "";
  566. $tmpStr = substr($tmpListArr["4"],strpos($tmpListArr["4"],"href=\"")+strlen("href=\""));
  567. $this->torrentFile = substr($tmpStr,0,strpos($tmpStr,"\""));
  568. // Size of File
  569. $this->torrentSize = $this->cleanLine($tmpListArr["7"]);
  570. // Seeds
  571. $this->Seeds = $this->cleanLine($tmpListArr["10"]);
  572. // Peers
  573. $this->Peers = $this->cleanLine($tmpListArr["11"]);
  574. if ($this->Peers == '')
  575. {
  576. $this->Peers = "N/A";
  577. if (empty($this->Seeds)) $this->Seeds = "N/A";
  578. }
  579. if ($this->Seeds == '') $this->Seeds = "N/A";
  580. //set torrent display name
  581. $this->torrentDisplayName = $this->torrentName;
  582. if(strlen($this->torrentDisplayName) > 50)
  583. {
  584. $this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."...";
  585. }
  586. //Check Date.
  587. if (!empty($tmpListArr["12"])) {
  588. $this->dateAdded = $this->cleanline($tmpListArr["12"]);
  589. }
  590. }
  591. }
  592. }
  593. function cleanLine($stringIn,$tags='')
  594. {
  595. if(empty($tags))
  596. return trim(str_replace(array("&nbsp;","&nbsp")," ",strip_tags($stringIn)));
  597. else
  598. return trim(str_replace(array("&nbsp;","&nbsp")," ",strip_tags($stringIn,$tags)));
  599. }
  600. //----------------------------------------------------------------
  601. // Function to build output for the table.
  602. function BuildOutput($bg, $searchURL)
  603. {
  604. $output = "<tr>\n";
  605. $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";
  606. $output .= " <td bgcolor=\"".$bg."\"><a href=\"dispatcher.php?action=urlUpload&type=torrent&url=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a></td>\n";
  607. if (strlen($this->MainCategory) > 1){
  608. if (strlen($this->SubCategory) > 1){
  609. $mainGenre = "<a href=\"".$searchURL."&mainGenre=".$this->MainId."\">".$this->MainCategory."</a>";
  610. $subGenre = "<a href=\"".$searchURL."&subGenre=".$this->SubId."\">".$this->SubCategory."</a>";
  611. $genre = $mainGenre."-".$subGenre;
  612. }else{
  613. $genre = "<a href=\"".$searchURL."&mainGenre=".$this->MainId."\">".$this->MainCategory."</a>";
  614. }
  615. }else{
  616. $genre = "<a href=\"".$searchURL."&subGenre=".$this->SubId."\">".$this->SubCategory."</a>";
  617. }
  618. $output .= " <td bgcolor=\"".$bg."\">". $genre ."</td>\n";
  619. $output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n";
  620. $output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n";
  621. $output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n";
  622. $output .= "</tr>\n";
  623. if (!empty($this->dateAdded)){
  624. $output .= "<tr bgcolor=\"\"> <td colspan=\"6\" align=center>".$this->dateAdded."</td></tr>\n";
  625. }
  626. return $output;
  627. }
  628. }
  629. ?>