handbook
suggest
notice

Archive

Archive for the ‘Programming’ Category
language

Recover WordPress from broken theme

April 26th, 2010 5 comments

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

UPDATE wp_options SET option_value = 'default'
WHERE option_name IN ('template','stylesheet','current_theme');

(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.

careers
guidelines

PHP: Validate an IP Address

March 13th, 2010conditions 2 comments

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

1
2
3
4
5
6
7
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;
}

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...

content

Install Ejabberd 2.0 on Ubuntu Hardy Heron 8.04 LTS - 6 Steps!

November 12th, 2009 2 comments

Problem:

You've chosen the most simple, solid Linux server - Ubuntu 8.04 LTS, and you want to run the most simple, solid XMPP server - ejabberd. BUT, the version of ejabberd in Hardy's repositories is the really old (Sep 03, 2007!) 1.1.4 release.

Solution:

You could of course build ejabberd from source, but that's not why you chose the "It Just WorksTM" Ubuntu server, is it? Have no fear. A simple and (mostly) painless solution awaits!

Read more...

participate