Share Pastebin
Guest
Public paste!

bheesham persaud

By: a guest | Oct 25th, 2009 | Syntax: PHP | Size: 10.29 KB | Hits: 100 | Expires: Never
Copy text to clipboard
  1. ==iNFO==
  2. Mod Name: Advanced Blacklist
  3. Mod Version: BETA
  4. Mod Author: bheesham
  5. Mod Description: A better blacklist.
  6. Mod Notes: Okay, instead of that hard to understand
  7. text... I'm just going to type it out so that normal
  8. people can understand it. XD
  9. ==/iNFO==
  10. ==iNSTaLL==
  11.  
  12.  
  13. K, now then.
  14.  
  15. Here's the code for admin_whitelist();
  16.  
  17. ==CODE==
  18. function admin_whitelist() {
  19. $bwurl = $_POST['bwurl'];
  20. $bwsub = $_POST['bwsub'];
  21. $remove = $_POST['remove'];
  22.         if($bwsub) {
  23.  
  24.                 if($bwurl) {
  25.                         @mysql_query("INSERT INTO wcddl_whitelist VALUES ('".mysql_real_escape_string($bwurl)."')");
  26.                         echo 'URL has been whitelisted.';
  27.                 }
  28.  
  29.                 if($remove) {
  30.                 $fishpan = 0;
  31.                         foreach($remove as $url) {
  32.                         mysql_query("DELETE FROM wcddl_whitelist WHERE url = '".mysql_real_escape_string($url)."'");
  33.                         $fishpan++;
  34.                         }
  35.                 echo $fishpan.' sites were Removed from the whitelist.';
  36.                 }
  37.         }
  38. echo '<form action="" method="post"><table width="100%">
  39. <tr><td>URL</td><td align="right">Remove</td></tr>';
  40. $get = mysql_query("SELECT url FROM wcddl_whitelist");
  41.         while($row = mysql_fetch_assoc($get)) {
  42.         echo '<tr><td><a href="http://'.$row['url'].'" target="_blank">'.$row['url'].'</a></td><td align="right"><input type="checkbox" name="remove[]" value="'.$row['url'].'"></td></tr>';
  43.         }
  44. echo '<tr><td colspan="2" align="right"><input type="submit" value="Remove Selected" name="bwsub"></td></tr>
  45. </table></form><br>
  46. <form action="" method="post"><table width="100%">
  47. <tr><td align="center">whitelist an URL</td></tr>
  48. <tr><td align="center">DO NOT INCLUDE WWW., HTTP:// or a directory! ONLY THE HOST NAME<br><input type="text" name="bwurl"></td></tr>
  49. <tr><td align="center"><input type="submit" value="whitelist" name="bwsub"></td></tr></table></form>';
  50. }
  51. ==/CODE=
  52.  
  53.  
  54. Now then. here is the code for admin_blacklist();
  55.  
  56. ==CODE==
  57.  
  58. function admin_blacklist() {
  59. echo <<<TMP
  60. <a href="?go=blacklist&amp;add">Add site to blacklist</a><br><br>
  61. <a href="?go=blacklist&amp;view">View the blacklist</a><br><br>
  62. TMP;
  63.  
  64. if (isset($_GET['add'])) {
  65. if (isset($_POST['addblacklist']) && !empty($_POST['blurl']) && !empty($_POST['blreason'])) {
  66. $blurl = $_POST['blurl'];
  67. $blurl = purl(str_replace("www.","",$blurl),"host");
  68. $blurl = htmlentities($blurl);
  69. $blurl = addslashes($blurl);
  70. $blurl = strtolower($blurl);
  71.  
  72. $blreason = $_POST['blreason'];
  73.  
  74. $blreason = str_replace("\r\n", '<br />', $blreason);
  75. $blreason = str_replace("\n", '<br />', $blreason);
  76. $blreason = str_replace("\r", '<br />', $blreason);
  77. $blreason = addslashes($blreason);
  78.  
  79. $time = time();
  80.  
  81. if (!empty($blurl)) {
  82. $exists = mysql_query('SELECT * FROM wcddl_blacklist WHERE url="'.addslashes($blurl).'"');
  83. if (mysql_num_rows($exists)==0) {
  84. mysql_query('INSERT INTO wcddl_blacklist (url,date,reason) VALUES ("'.$blurl.'", "'.$time.'", "'.$blreason.'")');
  85.  
  86. $sid = mysql_query("SELECT id FROM wcddl_sites WHERE url = '".mysql_real_escape_string($blurl)."'");
  87. $sid = mysql_result($sid,"id");
  88. mysql_query("DELETE FROM wcddl_downloads WHERE sid = '".mysql_real_escape_string($sid)."'");
  89. mysql_query("DELETE FROM wcddl_queue WHERE sid = '".mysql_real_escape_string($sid)."'");
  90.  
  91. echo $blurl.' has been added to the blacklist for:<br> '. stripslashes($blreason) . '<br><br><br>';
  92. }
  93. else
  94. {
  95. echo "$blurl is already blacklisted.<br><br><br>";
  96. }
  97. }
  98. else
  99. {
  100. echo "ERROR! Please take a look at the URL again... make sure that it has the HTTP:// in front of it.<br><br><br>";
  101. }
  102. }
  103. echo <<<TMP
  104. <form action="" method="post">
  105. <small>Site URL (You need to add the HTTP:// infront, the script will validate it):<small><br>
  106. <input type="text" name="blurl" /><br><br>
  107. <small>Reason (HTML is allowed. Just dont use \'s):</small><br>
  108. <textarea name="blreason" style="width: 50%;" rows="10"></textarea><br><br>
  109. <input type="submit" name="addblacklist">
  110. </form>
  111. TMP;
  112.  
  113. echo '<br /><br />';
  114. echo 'Quick BL<br /><br />';
  115. echo '
  116. <p style="float: left;">
  117. No link back<br />
  118. <textarea cols="5" rows="5" onfocus="this.select();">You do not link back to <a href="index.php">File Empire</a>.
  119. You <strong>MUST</strong> link back to us. Get the code <a href="submit.php">here</a>.
  120. <br />
  121. Be sure to read the <a href="submit.php">Rules</a> carefully.
  122. </textarea>
  123. </p>
  124. <p style="float: right;">
  125. Down or not funtioning<br />
  126. <textarea cols="5" rows="5" onfocus="this.select();">Your site is either down or not functioning properly.
  127. Email the webmaster when the issue has been resolved.
  128. <br />
  129. Be sure to read the <a href="submit.php">Rules</a> carefully.</textarea>
  130. </p>
  131. <br />
  132. <p style="float: left;">
  133. Spam<br />
  134. <textarea cols="5" rows="5" onfocus="this.select();">Your site has submitted spam.
  135.  
  136. <br />
  137. Be sure to read the <a href="submit.php">Rules</a> carefully.</textarea>
  138. </p>
  139.  
  140. <p style="float: right;">
  141. Does not exist<br />
  142. <textarea cols="5" rows="5" onfocus="this.select();">The site does not exist.
  143.  
  144. <br />
  145. Be sure to read the <a href="submit.php">Rules</a> carefully.</textarea>
  146. </p>
  147.  
  148. <p style="float: left">
  149. Duplicate Site<br />
  150. <textarea cols="5" rows="5" onfocus="this.select();">This is a duplicate of another site.
  151.  
  152. <br />
  153. Be sure to read the <a href="submit.php">Rules</a> carefully.</textarea>
  154. </p>
  155.  
  156. <p style="float: right">
  157. Does not link directly to download page.<br />
  158. <textarea cols="5" rows="5" onfocus="this.select();">You do not link directly to the download page.
  159.  
  160. <br />
  161. Be sure to read the <a href="submit.php">Rules</a> carefully.</textarea>
  162. </p>
  163. <p style="float: left">
  164. Submits duplicate downloads<br />
  165. <textarea cols="5" rows="5" onfocus="this.select();">You submit duplicate downloads.
  166.  
  167. <br />
  168. Be sure to read the <a href="submit.php">Rules</a> carefully.</textarea>
  169. </p>
  170.  
  171. ';
  172. }
  173.  
  174. if (isset($_GET['view'])) {
  175.  
  176. if (isset($_POST['delete'])) {
  177. mysql_query('DELETE FROM wcddl_blacklist WHERE id="'.$_POST['delete'].'"');
  178. echo 'Deleted site with ID ' . $_POST['delete'] . ' the blacklist.';
  179. }
  180.  
  181. if (isset($_POST['edit'])) {
  182. echo '<form action="" method="post">';
  183.  
  184. $getble = mysql_query('SELECT * FROM wcddl_blacklist WHERE id="'.$_POST['edit'].'"');
  185.  
  186. if (mysql_num_rows($getble) == 1) {
  187. while($dude = mysql_fetch_assoc($getble)) {
  188. echo <<<TMP
  189. <input type="hidden" name="id" value="{$dude[id]}"><br>
  190. <small>Site URL (Include the HTTP:// again please):</small><br>
  191. <input type="text" name="blurl" value="http://{$dude[url]}" /><br>
  192. <small>Reason (NO HTML just BBCode!)</small><br>
  193. <textarea name="blreason" style="width: 50%;" rows="10">{$dude[reason]}</textarea><br><br>
  194. TMP;
  195. }
  196. }
  197.  
  198. echo '<input type="submit" name="fined" value="Finish Editing" />';
  199. echo '</form>';
  200. }
  201.  
  202. $getbl = mysql_query('SELECT * FROM wcddl_blacklist ORDER BY id DESC');
  203. if (mysql_num_rows($getbl) != 0) {
  204. echo '<form action="" method="post"><table style="width: 100%;">';
  205. echo '<tr><td style="width: 50%;">URL - Date</td><td style="width: 25%;">DELETE</delete></tr>';
  206. while($bl = mysql_fetch_assoc($getbl)) {
  207. $date = date('d-m-Y', $bl[date]);
  208.  
  209. echo <<<TMP
  210. <tr>
  211. <td><a href="http://{$bl[url]}">{$bl[url]} - {$date}</td>
  212. <td><input type="submit" name="delete" value="{$bl[id]}" style="width: 100%;" /></td>
  213. </tr>
  214. TMP;
  215. }
  216. echo '</table></form>';
  217. }
  218. else
  219. {
  220. echo "No sites in blacklist";
  221. }
  222. }
  223.  
  224. }
  225.  
  226. ==/CODE==
  227. And yes, You replace the old code with the new codes above.
  228.  
  229.  
  230.  
  231. Now then. If you DO NOT have any sites in your blacklist... then you can use this code.
  232. ==CODE==
  233. SET FOREIGN_KEY_CHECKS=0;
  234.  
  235. DROP TABLE IF EXISTS `wcddl_blacklist`;
  236. CREATE TABLE `wcddl_blacklist` (
  237.   `id` int(11) NOT NULL auto_increment,
  238.   `url` varchar(255) NOT NULL,
  239.   `date` varchar(255) NOT NULL,
  240.   `reason` mediumtext NOT NULL,
  241.   PRIMARY KEY  (`id`)
  242. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  243. ==/CODE==
  244.  
  245.  
  246. If you already have a blacklist... then you'll have to insert each URL in with this query...
  247. Later on there may be an easier way... but I doubt it cuz i have other stuff i want to code.
  248. ==CODE==
  249. INSERT INTO wcddl_blacklist (url,date,reason) VALUES ('[SITE URL]', '1255541430', "[REASON]")
  250. ==/CODE==
  251.  
  252. When you're inserting sites... make sure that there is NO trailing slashes OR http://www. OR http:// in them.
  253. So if You wanted to blacklist lets say... http://www.warezcoders.com/forum
  254.  
  255. OR <-- Yes.. there is an alternative.
  256.  
  257. You can copy all of the URL's that you blacklisted already into a text file, then use
  258. the admin panel of the BlackList to add them. A lot faster. A lot easier.
  259.  
  260. If you have too much sites in your blacklist then.. its gunna be a long day for you if you really want to use it.
  261.  
  262. You would actually put just warezcoders.com
  263.  
  264. get it? if you dont, read it over again.
  265.  
  266. Well... now its time to show the user the blacklist. Or else this would kind of been useless.
  267.  
  268. Here is the code for that. Make sure tht you include funcs.php
  269. ==CODE==
  270. <form action="" method="post">
  271. <p>
  272. Site URL (http:// is required): <input type="text" name="blurl" value="http://" /> <input type="submit" name="blsear" />
  273. </p>
  274. </form>
  275.  
  276.  
  277. <table style="width: 100%;">
  278. <tbody>
  279. <tr>
  280. <th style="width: 30%">URL</th>
  281. <th style="width: 70%">Reason &amp; Date</th>
  282. </tr>
  283. <?php
  284. $where = null;
  285. if (isset($_POST['blsear'])) {
  286. $blurl = $_POST['blurl'];
  287. $blurl = purl(str_replace("www.","",$blurl),"host");
  288. $blurl = htmlentities($blurl);
  289. $blurl = addslashes($blurl);
  290. $blurl = strtolower($blurl);
  291. if (!empty($blurl)) {
  292. $where = ' WHERE url LIKE "%'.$blurl.'%"';
  293. }
  294. }
  295.  
  296. $getbl = mysql_query('SELECT * FROM wcddl_blacklist '.$where.' ORDER BY id DESC LIMIT 50');
  297. $alternate = 0;
  298. if (mysql_num_rows($getbl) != 0) {
  299. while($inf = mysql_fetch_assoc($getbl)) {
  300. if ($alternate == 0) {
  301.         echo '<tr>';
  302.         $alternate = 1;
  303. }
  304. else
  305. {
  306.         echo '<tr>';
  307.         $alternate = 0;
  308. }
  309.        
  310.        
  311. $reason = stripslashes($inf['reason']);
  312. $reason = str_replace(' />', '>', $reason);
  313. $reason = str_replace('<br><br>', '<br>', $reason);
  314. $date = date('d-m-Y', $inf['date']);
  315. echo <<<TMP
  316. <td style="border-bottom: 2px solid;">{$inf['url']}</td>
  317. <td style="border-bottom: 2px solid;"><p>$reason <br>Blacklisted on: $date</p></td>
  318. </tr>
  319. TMP;
  320. }
  321. }
  322. else
  323. {
  324. echo '<tr><td style="color: #FFF;" colspan="2">No search met your criteria.</td></tr>';
  325. }
  326. ?>
  327. </tbody>
  328. </table>
  329. ==/CODE==
  330.  
  331. O, it would be great if you could link back to my site.
  332.  
  333. http://file-empire.com/
  334.  
  335. if you dont... then don't expect me to give any support.
  336. ==/iNSTaLL==
  337. ==MaNuaL iNSTRuCTiONS==
  338. None. Just try to link back to
  339. http://file-empire.com on your website.
  340. ==/MaNuaL iNSTRuCTiONS==