Recover WordPress from broken theme

If you ever find yourself with a broken theme and can’t even access the admin side of your wordpress blog, here’s a quick way to get back on your feet.

Simply run the following query from the command line or via a tool like phpMyAdmin

[cc lang=’mysql’ line_numbers=’false’]
UPDATE wp_options SET option_value = ‘default’
WHERE option_name IN (‘template’,’stylesheet’,’current_theme’);
[/cc]
(Make sure to select your wordpress database first, of course)

Sure. Your site looks like it was just setup 2 seconds ago, but at least now you can access all the GUI-licious tools of the WordPress Admin panel to fix whatever broke your theme.

PHP: Validate an IP Address

So you need to check if some string is a valid IP address. You could simply test it against a regular expression:

[cc lang=’php’ ]
function is_valid_ipv4($ip)
{
return preg_match(‘/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.’.
‘(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.’.
‘(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.’.
‘(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/’, $ip) !== 0;
}
[/cc]
Regular Expression obtained here

This will actually work for most situations, but it’s lacking in a few ways. Suppose you want to exclude private or reserved IP addresses. Maybe you want to validate IPv6 addresses too; not just IPv4.

Enter PHP’s Data Filtering Extension. It just works, and you don’t have to worry about maintaining (or properly applying) complex regular expressions.

Read More

RFC Standard for the transmission of IP datagrams on Avian Carriers

Nerd alert: This post contains off-the-charts geek humor. You’ve been warned.

Thanks to my friend who sent me this.

Uber-geeks will recognize “RFC” (yet another TLA) as short for “Request For Comments.” But those with lives normal folks might need an explanation.

The Internet Engineering Task Force (IETF) has created RFC as a standard for documentation of Internet-related subjects. There is an RFC for just about everything, including:

A lot of RFC’s are standards, but the vast majority of them are not. Almost all of them, though, are painfully dry reads. That said, there are some glaring exceptions.

Read More