One feature that is missing in WordPress is a decent way to filter out comments by IP Address. I decided to tackle that today. First I will do it via a quick hack and then expand it to more tightly integrate with the backend. If someone would like to figure out how to make it a plugin, that would be awesome.
- First you need to add a table to the WordPress database. I named mine wp_banned and added a simple column: IpAddress.
- Open up /wp-includes/comment.php and look around line 676 for the wp_new_comment function. Add the following to the beginning:
1
2
3
4
5
6
7
| global $wpdb;
$testIp = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
$ipResults = $wpdb->get_results("SELECT * FROM wp_banned WHERE IpAddress = '".$testIp."'");
if(count($ipResults) > 0)
return -1; |
- Upload, add ips to the database and then watch them not appear anymore.
Now I just need to figure out how to add some nice buttons to the comment page to “Ban and Spam” comments…
I do not understand why the difference between ASP.NET and PHP hosting is so gigantic. They are completely different beasts and I understand that most if not all hosts running ASP.NET are using Windows Server to do so, but why are the packages and reliability so different? It doesn’t make sense to me that on a PHP host you can get the same reliability as an ASP.NET host for the same price with one major difference: the PHP host gives you gobs of bandwidth and space. Here are some hosts and what I have experienced so far (from worst to best)…
WebHost4Life
ASP.NET, PHP, etc. and Unlimited Bandwidth
WebHost4Life was one of my first ASP.NET hosts and was used largely because I could run PHP alongside my normal web apps. This is a huge plus since I run a PHP-based forum and did not want to force my users to recreate their users, et cetera. So what was the problem with WebHost4Life? Daily downtime of an hour or more at roughly 2AM GMT -5 due to the AppPool being reset. This is completely unecessary and about the worse thing a host could ever do, especially when claiming 99% reliability.
BlueHost
PHP, unlimited everything
BlueHost was my first real host and I have had my account for over two years now. What can I say about them other than they are amazing, especially for Shared hosting. I am running three sites on them now and am having no problems so far with scalability. But because accounts are so cheap compared to ASP.NET hosts, I can easily buy a second or a third if need be. Only problem? The CEO has told me in a private e-mail that he will never support ASP.NET on BlueHost, ever. Saddening because they could do great things for the ASP.NET world.
Reliable Site
ASP.NET, PHP
Reliable Site has been a great host for me up until recently. They were always great on support and always willing to help me out. Reliability was top notch: I didn’t experience a single second of downtime on my Clustered account, even when hosting four sites. The problem? They expect you to pay $8 a month for a mere 40gb of extra bandwidth on a rolling schedule. That means that bandwidth isn’t calculated per month but per last 30 days. This may be nice if you have consistent days, but spikes can ruin your bandwidth for 30 days. You have no chance of timing a release for the last 2-3 days of a month because it won’t matter.
I have experienced other hosts but they really aren’t worth mentioning. I just wish I could find a host that did what ReliableSite does but was easier on the bandwidth pricing. Especially when DreamHost, BlueHost and several others offer 5tb and more of bandwidth per month for less money.