mark.watero.us

Wordpress stuff, a statistics plugin, and jello

Articles found in the ‘General’ pigeonhole

5,000 downloads, and a little mod-security

leave a comment

kStats Reloaded just passed 5,000 downloads!

Thank you to everyone who has been part of the development, by supporting the plugin through using it, writing about it in your blogs, sending me feedback via comments, email or bug reports, and anything I missed mentioning! It’s been a lot of fun, and I hope to see it continue growing in popularity.

I’ve got a list a mile long of new features that are up and coming, and I’m currently working on yet more improvements to the database structure as we speak in further attempts to ensure that this is not only an accurate and feature rich plugin, but a lil’ speed demon too. Again, thank you all, and don’t be shy about sending me your criticisms or suggestions!

Mod What?

I just recently installed Mod Security on my server in an attempt to reduce the number of attacks on my blog and the ridiculous referrer spam that I’ve been getting lately. I’m sorry, but I have no interest in taking a screenshot of the latest kStats and showing everybody that 5 out of ten of my top referrers are coming from some stupid subdomain of a**f***d****.com (you’ll notice the most recent screenshot has the top referrers chart collapsed for a reason).

While it deals mainly in HTTP and regular expressions, of which I’m familiar with, the syntax is completely new to me. I hope I haven’t turned on any rules that result in any odd behaviour for anyone; If you notice anything out of the ordinary while trying to perform common tasks such as leaving comments, please let me know so that I can fix it asap. I already had to rewrite a few rules because I managed to make it believe using phpMyAdmin was some form of attempted SQL injection attack…

Written by mark

December 4th, 2009 at 12:46 am

To the recent RFI attempts on my site…

leave a comment

I doubt any of you script kiddiez even look at the sites you attempt to hack with your little botnet and RFI scripts, but in case you do, I just have one question for the lot of you;

Does your grandma know what you’re doing in her rent-free basement?

I’m sorry, I realize most of you probably live at home with mommy and daddy, and I shouldn’t be bringing your grandmother’s into this, but seriously. Half of you tried to attack my site with a phpBB vulnerability. I’m sorry, last time I checked, I was running Wordpress.

Put down the porn, sign off your favorite MMORPG, change your clothes and shower for once in your life and walk to the front of your house. There’s a big rectangle there with a little round knobby thing on it. This is called the front door. If you open it, there’s a life somewhere out there for you. Go find it.

You’re not getting root on my box, trust me. I’m sure a skilled hacker could if they put enough effort into it, but you’re not.

I don’t know who amongst my readers might have the skills and the time, but if you want to slap some children around with a big trout, here’s a few IPs from my logs;

61.63.10.150
64.6.232.171
194.105.193.46
209.216.213.119

Have a nice day!

Written by mark

November 21st, 2009 at 4:28 pm

Posted in General

Tagged with ,

Ed Hardy, you may need to try again.

leave a comment

wordpress-energy

FAIL.

My wife nearly passed out cold after we tried your energy shots Ed. They don’t work.

Written by mark

November 3rd, 2009 at 2:21 am

Posted in General

Tagged with ,

is_child(), a function for finding your parent

leave a comment

Working on my pet project, I came across a conditional that was very conspicuously missing from the Wordpress core template functions. Where has my is_child() been misplaced?

Building web sites using Wordpress, you’ve probably more than once found yourself using various conditional tags to determine whether you’re on a page, a category, a blog entry, or something else. You can specify exactly what page you’re looking for with is_page(), whether you’re on the front page with is_home(), or whether you’re visiting an archive page with is_archive(). But what if you’d like to know who your parent was, or if you even had one?

I know who my parents are, they were introduced to me by the doctor, and over the years we eventually got to a point where we could remember each others names. It’s a little trickier to know who your parent is in Wordpress, though altogether not very difficult. You can check your $post object to see if you have a parent, and run get_post() if you’d like to know your parents name.

But what if you need to check this often?

Instead of writing the same few checks over and over again on various pages or in different functions, it would be nice if Wordpress had an is_child() function as part of the core. So I wrote one, and I believe in laziness, and everyone else’s right to that same laziness.

My code highlighter has gone on vacation, and I haven’t got the time right now to call in a substitute… sorry! Seems to be working again.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function is_child ($of_page = NULL) {
	global $post;
 
	if (! $post->post_parent || ! is_page())
		return FALSE;
 
	if (! isset($of_page))
		return TRUE;
	else if ($of_page == $post->post_parent)
		return TRUE;
	else if ($of_page == get_post($post->post_parent)->post_name)
		return TRUE;
 
	return FALSE;
}

Add this as a plugin, or in your functions.php, and you can use it in the same way you would use is_page();

1
2
3
if ( is_child() )  // returns true if the page is a child of any 
if ( is_child(12) )  // returns true if the parent ID is 12
if ( is_child('about') )  // returns true if the page slug of the parent is 'about'

Enjoy!

Written by mark

September 22nd, 2009 at 9:40 pm

Posted in Code Snippets, General

Tagged with , ,

Built-in maintenance mode, or ‘Bringing down the house’

leave a comment

If you happen to run a large Wordpress powered site, you might be interested to know that there’s a little known gem of core functionality for placing your site into maintenance mode. This allows you to make upgrades, perform database operations, or do any number of potentially disruptive tasks without affecting any of your bloggers.
Read the rest of this entry »

Written by mark

September 11th, 2009 at 12:08 am

Posted in General

Tagged with ,