WordPress get_links

Actually I was only trying to get the list of links in the sidebar sorted by the time of their last update. Naïvely, I tried to just pass get_links() the ‘_updated’ parameter, but it didn’t work. Since the codex is more or less down, and googling using a search engine didn’t help much, I resorted to just reading the fine code. So, to answer my own questions for posteriority and those using a search engine to find out about get_links:

  1. passing ‘_updated’ should work; contrary to what some believe, it does not sort by ‘time you last edited the link’, but really tries to sort on ‘time the link last updated’;
  2. if it does not work, that’s probably because api.pingomatic.com is timing out since forever, despite ‘servers donated by automattic’;
  3. all blogroll-updating plugins I found do all sorts of weird things, but don’t work in the end; I for one t hink that asking any number of services for all changes they registered in the last 5 or 10 minutes and then manually filtering for entries in ones blogroll is, well, overkill, not to mention that it causes a load of unnecessary traffic on both ends;
  4. as of now, there doesn’t seem to be a plugin that does the obvious thing, namely to just check the goddamn RSS feeds I manually entered for every link in my blogroll!

which leads us to

  1. link lists in WordPress are in a sorry state of affairs, and
  2. I should probably write such a plugin.

Getting rid of the ‘www’ prefix

[lang_de]Dieser Eintrag ist nur auf Englisch verfügbar.[/lang_de]

You may or may not have heard about the no-www movement. All my sites have always been reachable with and without the www prefix, and I personally never use the www prefix if I can avoid it. I won’t get into the details of why it is a bad idea, but consider this: no one calls the web ‘WWW’ anymore, and this ‘abbreviation’ is a lot longer than the expansion (‘double-you double-you double-you’ vs ‘world wide web’). If anything, the prefix should be ‘web’.

Starting today, I’m having all my domains permanently redirect to the non-www version of the hostname.

Here’s a simple mod_rewrite recipe that should work for any domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L,NS]

Put it inside a <Location "/"> block in the appropriate VirtualHost block, or inside a .htaccess in the document root of your site (it doesn’t seem to work in a VirtualHost block in the server config, any ideas why?).

It’s like magic.

IP to country: ip2countryd using hostip.info data

[lang_de]Dieser Eintrag ist nur auf Englisch verfügbar.[/lang_de]

hostip.info is a free GeoIP service. Unfortunately their webservice is slow and they are in the middle of a backend change (from 256 ip_X tables to one table listing all /24 nets…). However, their information is more exact than that of countries.nerd.dk.

To convert the data from hostip.info’s format into something remotely sane usable, you have to merge the ranges into CIDR-blocks per country. If you don’t do that, you’ll get a 160MiB result file which will take ages for ip2countryd to process. With proper optimization and merging, though, the resulting file is barely 4MiB in size and ip2countryd loads like a breeze.

  • ip2countryd-r3.tgz 12KiB
    Revision 3 of ip2countryd, minor changes, includes a script to convert hostip.info CSV dumps to rbldnsd format.
  • hostip-data.tgz 1.1MiB
    The current dump from hostip.info in rbldnsd format, including the cached version.

The test service at udp://ubermutant.net:8000/ has been updated to r3 with the hostip.info db.

Now, for the rant. Continue reading “IP to country: ip2countryd using hostip.info data”

IP to country

[lang_de]Dieser Eintrag ist nur auf Englisch verfügbar.[/lang_de]

If you need to find out what country an IP is in, but are forced to use PHP or some other language without proper DNS querying features (but which can do UDP), here’s a little something for you.

ip2countryd-r2.tgz 344KiB – ip2countryd revision 2
Includes the required data file (~2MiB) and the cached data (~432KiB).

Runs a daemon on UDP port 8000 (by default) that responds to an input IP address with the ISO country code of the IP’s country, or ‘error’ if anything goes wrong (no mapping, not an IP, etc.). There is a test server at udp://ubermutant.net:8000/.

$ nc -u ubermutant.net 8000
207.13.77.53
us
212.227.57.11
eu

Idea from WP-ShortStat and the associated ip2country service. I wrote this just for the fun of it and because I wanted to see how long it would take me.

Total time required: ~1 hour.

[lang_en]WordPress Statistics[/lang_en][lang_de]WordPress-Statistiken[/lang_de]

[lang_en]
I recently installed WP-ShortStat to gather blog statistics, and especially to make them more easily accessible (compared to webalizer). WP-ShortStat claims that one should just drop it in the plugin directory and enable it and it would work. Well, guess what happened.
[/lang_en]
[lang_de]
Ich habe vor kurzem WP-ShortStat installiert, um mal einfach verfügbare und lesbare (im Gegensatz zu Webalizer) Blog-Statistiken zu haben. WP-ShortStat behauptet, man müsses nur einfach nur ins Plugin-Verzeichnis legen, das Plugin anschalten, und es würde funktionieren. Ratet, was statt dessen passiert ist.
[/lang_de]
Continue reading “[lang_en]WordPress Statistics[/lang_en][lang_de]WordPress-Statistiken[/lang_de]”

UX UX UX (in multiple languages)

You are HP-UX. You're still strong despite the passage of time.  Though few understand you, those who do love you deeply and appreciate you.
Which OS are You?

[lang_de]
Hurrah. Hat irgendwie was von Horoskopen.

Eigentlich teste ich nur das Polyglot-Plugin. Es funktioniert, aber der Code schreit eigentlich nach einem Rewrite… später.

Augen nach oben rechts wenden, lustige kleine Flaggen sehen, ausprobieren, und hoffentlich keine Fehler finden… jetzt. 😉
[/lang_de]

[lang_en]
Huzzah. Feels a little like horoscopes.

Actually I’m just testing the Polyglot plugin. It works, but the code is literally screaming for a rewrite… later.

Look to the upper right corner, see the nifty little flags, try them, hopefully don’t find any bugs… now. 😉
[/lang_en]

Case-sensitive MediaWiki

I just finished setting up a MediaWiki for WorldIRC. Page titles and user names should be fully case-sensitive (i.e., able to start with a lowercase letter). Unfortunately, MediaWiki doesn’t really support that out of the box. Googling didn’t yield any usable results. Finally, asking in the IRC channels got me on the right track: In your LocalSettings.php, add at the end:

$wgCapitalLinks = false;

To get case-sensitive usernames, but still allow case-insensitive logins, you need to patch the code.
Here’s my patch against the current stable 1.6 version (r14760):

Continue reading “Case-sensitive MediaWiki”