Guest User

Untitled

a guest
Jul 15th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.99 KB | None | 0 0
  1. <?
  2.  
  3. ob_start("ob_gzhandler");
  4. require_once("include/bittorrent.php");
  5. loggedinorreturn();
  6. $wherethisuser = where ($_SERVER["SCRIPT_FILENAME"],$CURUSER["id"]);
  7. parked();
  8. $cats_colors = array ('#0033FF', '#00CC00', '#FF0000', '#FF0099', '#B67371', '#00CC00', '#FF66FF','#0033FF', '#00CC00', '#FF0000', '#FF0099', '#B67371', '#00CC00', '#FF66FF','#0033FF', '#00CC00', '#FF0000', '#FF0099', '#B67371', '#00CC00');
  9. $cats = genrelist();
  10.  
  11. $searchstr = unesc($_GET["search"]);
  12. $cleansearchstr = searchfield($searchstr);
  13. if (empty($cleansearchstr))
  14. unset($cleansearchstr);
  15.  
  16. $orderby = "ORDER BY torrents.sticky ASC, torrents.id DESC";
  17.  
  18. $addparam = "";
  19. $wherea = array();
  20. $wherecatina = array();
  21.  
  22. if ($_GET["incldead"] == 1)
  23. {
  24. $addparam .= "incldead=1&";
  25. if (!$CURUSER || get_user_class() < UC_ADMINISTRATOR)
  26. $wherea[] = "banned != 'yes'";
  27. }
  28. elseif ($_GET["incldead"] == 2)
  29. {
  30. $addparam .= "incldead=2&";
  31. $wherea[] = "visible = 'no'";
  32. }
  33. elseif ($_GET["incldead"] == 3)
  34. {
  35. $addparam .= "incldead=3&";
  36. $wherea[] = "free = 'yes'";
  37. $wherea[] = "visible = 'yes'";
  38. }
  39. else
  40. $wherea[] = "visible = 'yes'";
  41.  
  42. $category = (int)$_GET["cat"];
  43.  
  44. $all = $_GET["all"];
  45.  
  46. if (!$all)
  47. if (!$_GET && $CURUSER["notifs"])
  48. {
  49. $all = True;
  50. foreach ($cats as $cat)
  51. {
  52. $all &= $cat[id];
  53. if (strpos($CURUSER["notifs"], "[cat" . $cat[id] . "]") !== False)
  54. {
  55. $wherecatina[] = $cat[id];
  56. $addparam .= "c$cat[id]=1&";
  57. }
  58. }
  59. }
  60. elseif ($category)
  61. {
  62. if (!is_valid_id($category))
  63. stderr("Error", "Invalid category ID.");
  64. $wherecatina[] = $category;
  65. $addparam .= "cat=$category&";
  66. }
  67. else
  68. {
  69. $all = True;
  70. foreach ($cats as $cat)
  71. {
  72. $all &= $_GET["c$cat[id]"];
  73. if ($_GET["c$cat[id]"])
  74. {
  75. $wherecatina[] = $cat[id];
  76. $addparam .= "c$cat[id]=1&";
  77. }
  78. }
  79. }
  80.  
  81. if ($all)
  82. {
  83. $wherecatina = array();
  84. $addparam = "";
  85. }
  86.  
  87. if (count($wherecatina) > 1)
  88. $wherecatin = implode(",",$wherecatina);
  89. elseif (count($wherecatina) == 1)
  90. $wherea[] = "category = $wherecatina[0]";
  91.  
  92. $wherebase = $wherea;
  93.  
  94. if (isset($cleansearchstr))
  95. {
  96. $wherea[] = "MATCH (search_text, ori_descr) AGAINST (" . sqlesc($searchstr) . ")";
  97. //$wherea[] = "0";
  98. $addparam .= "search=" . urlencode($searchstr) . "&";
  99. $orderby = "";
  100. }
  101.  
  102. $where = implode(" AND ", $wherea);
  103. if ($wherecatin)
  104. $where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")";
  105.  
  106. if ($where != "")
  107. $where = "WHERE $where";
  108.  
  109. $res = mysql_query("SELECT COUNT(*) FROM torrents $where") or die(mysql_error());
  110. $row = mysql_fetch_array($res);
  111. $count = $row[0];
  112.  
  113. if (!$count && isset($cleansearchstr)) {
  114. $wherea = $wherebase;
  115. $orderby = "ORDER BY id DESC";
  116. $searcha = explode(" ", $cleansearchstr);
  117. $sc = 0;
  118. foreach ($searcha as $searchss) {
  119. if (strlen($searchss) <= 1)
  120. continue;
  121. $sc++;
  122. if ($sc > 5)
  123. break;
  124. $ssa = array();
  125. foreach (array("search_text", "ori_descr") as $sss)
  126. $ssa[] = "$sss LIKE '%" . sqlwildcardesc($searchss) . "%'";
  127. $wherea[] = "(" . implode(" OR ", $ssa) . ")";
  128. }
  129. if ($sc) {
  130. $where = implode(" AND ", $wherea);
  131. if ($where != "")
  132. $where = "WHERE $where";
  133. $res = mysql_query("SELECT COUNT(*) FROM torrents $where");
  134. $row = mysql_fetch_array($res);
  135. $count = $row[0];
  136. }
  137. }
  138.  
  139. $torrentsperpage = $CURUSER["torrentsperpage"];
  140. if (!$torrentsperpage)
  141. $torrentsperpage = 15;
  142.  
  143. if ($count)
  144. {
  145. list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam);
  146. $query = "SELECT torrents.id, torrents.dupla_seed, torrents.category, torrents.leechers, torrents.seeders, torrents.sticky, torrents.name, torrents.free, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.description, torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav," .
  147. "IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
  148. "categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
  149. $res = mysql_query($query) or die(mysql_error());
  150. }
  151. else
  152. unset($res);
  153. if (isset($cleansearchstr))
  154. stdhead("Search results for \"$searchstr\"");
  155. else
  156. stdhead();
  157.  
  158. ?>
  159. <form method="get" action="browse.php">
  160. <table class="bottom">
  161. <tr>
  162. <td class="bottom">
  163. <table class="bottom">
  164. <tr>
  165.  
  166. <?
  167. $i = 0;
  168. foreach ($cats as $cat)
  169. {
  170. $catsperrow = 7;
  171. print(($i && $i % $catsperrow == 0) ? "</tr><tr>" : "");
  172. print("<td align=center class=bottom style=\"padding-bottom: 2px;padding-left: 7px\"><input name=c$cat[id] type=\"hidden\" " . (in_array($cat[id],$wherecatina) ? "checked " : "") . "value=1><a class=catlink href=browse.php?cat=$cat[id]><img src=pic/" . htmlspecialchars($cat[image]) . "></a></td>\n");
  173. $i++;
  174. }
  175.  
  176. $alllink = "<div align=\"left\">(<a href=\"browse.php?all=1\"><b>Show all</b></a>)</div>";
  177.  
  178. $ncats = count($cats);
  179. $nrows = ceil($ncats/$catsperrow);
  180. $lastrowcols = $ncats % $catsperrow;
  181.  
  182. if ($lastrowcols != 0)
  183. {
  184. if ($catsperrow - $lastrowcols != 1)
  185. {
  186. print("<td class=\"bottom\" rowspan=" . ($catsperrow - $lastrowcols - 1) . ">&nbsp;</td>");
  187. }
  188. print("<td class=\"bottom\" style=\"padding-left: 5px\">$alllink</td>\n");
  189. }
  190. ?>
  191. </tr>
  192. </table>
  193. </td>
  194.  
  195. <td class="bottom">
  196. <table class="main">
  197. <tr>
  198. <td class="bottom" style="padding: 1px;padding-left: 10px">
  199. <select name="incldead"><option value="0">active</option>
  200. <option value="1"<? print($_GET["incldead"] == 1 ? " selected=\"selected\"" : ""); ?>>including dead</option>
  201. <option value="2"<? print($_GET["incldead"] == 2 ? " selected=\"selected\"" : ""); ?>>only dead</option>
  202. <option value="3"<? print($_GET["incldead"] == 3 ? " selected" : ""); ?>>FREE</option>
  203. </select>
  204. </td>
  205. <?
  206. if ($ncats % $catsperrow == 0)
  207. print("<td class=\"bottom\" style=\"padding-left: 15px\" rowspan=$nrows valign=\"center\" align=\"right\">$alllink</td>\n");
  208. ?>
  209.  
  210. </tr>
  211. <tr>
  212. <td class="bottom" style="padding: 1px;padding-left: 10px">
  213. <div align="center">
  214. <input type="submit" class="btn" value="Go!"/>
  215. </div>
  216. </td>
  217. </tr>
  218. </table>
  219. </td>
  220. </tr>
  221. </table>
  222. </form>
  223.  
  224. <?
  225.  
  226. if (isset($cleansearchstr))
  227. print("<h2>Search results for \"" . htmlspecialchars($searchstr) . "\"</h2>\n");
  228.  
  229. if ($count) {
  230. print($pagertop);
  231.  
  232. torrenttable($res);
  233. //torrenttable($res, "mytorrents");
  234.  
  235. print($pagerbottom);
  236. }
  237. else {
  238. if (isset($cleansearchstr)) {
  239. print("<h2>Nothing found!</h2>\n");
  240. print("<p>Try again with a refined search string.</p>\n");
  241. }
  242. else {
  243. print("<h2>Nothing here!</h2>\n");
  244. print("<p>Sorry pal :(</p>\n");
  245. }
  246. }
  247. mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);
  248. stdfoot();
  249.  
  250. ?>
Add Comment
Please, Sign In to add comment