Advertisement
Guest User

sfs importer

a guest
Feb 3rd, 2013
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.07 KB | None | 0 0
  1.  
  2. CREATE TABLE IF NOT EXISTS `stopforumspam` (
  3.   `ip` varchar(32) NOT NULL,
  4.   `id` int(32) NOT NULL auto_increment,
  5.   `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  6.   PRIMARY KEY  (`id`),
  7.   UNIQUE KEY `ip` (`ip`)
  8. ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=287040 ;
  9. ##IMPORTER SCRIPT
  10.  
  11. #!/bin/bash
  12. wget http://www.stopforumspam.com/downloads/bannedips.zip
  13. unzip ./bannedips.zip >>/dev/null
  14. rm newips.csv
  15. sed 's/,/\n/g' bannedips.csv > newips.csv
  16. P=password
  17. D=database
  18. U=user
  19. mysql -u$U -p$P  -D$D<<< 'TRUNCATE stopforumspam ; '
  20. mysql -u$U -p$P  -D$D<<< ' LOAD DATA LOCAL INFILE "./newips.csv" INTO TABLE stopforumspam FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY """" LINES TERMINATED BY "\n" (ip);'
  21.  
  22. ##BASH
  23.  
  24. //PHP
  25. $ip=$_SERVER['REMOTE_ADDR'];
  26. $result = dbquery("SELECT * FROM stopforumspam WHERE ip='".$ip."'"); //php-fusion query
  27.  $numrows = dbrows($result); //php-fusion query
  28. echo $numrows; //php-fusion query
  29. if($numrows=="1")
  30. {
  31. die('exit');
  32. // EXEC IPTABLES BAN $ip
  33. //FAIL2BAN FOR VSERVERS
  34. }
  35. //PHP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement