Archive for the 'Online' Category

 

OpenID 3.3.3 & WordPress 2.9.x

Sunday, August 29th, 2010 in Online, PHP

Today was WordPress maintenance Sunday for me. I sorted out all the spam Akismet hadn’t caught and updated a few of the plugins we are using with WordPress. However I hadn’t enough time to update WordPress itself to version 3.0.1. So we are still running 2.9.2. This caused some trouble when I was upgrading the OpenID plugin to its latest version 3.3.3. Accessing the WordPress admin panel I got stuck with an PHP error reading

Call to undefined function get_user_meta()

WordPress codex tells us this function get_user_meta is not available in WordPress until version 3.0. It is replacing the now deprecated function get_usermeta which is available for earlier versions of WordPress. So I came up with a little hack to get the OpenID plugin running again for my ancient 2.9.2 version of WordPress.

Simply add these lines at the top of the plugin files admin_panels.php, server.php and server_ext.php:

/**
* Hotfix for WordPress 2.x
*/
if ( !function_exists('get_user_meta') ) {
function get_user_meta($user_id, $key, $single = false) {
if ( $single == false )
return array(get_usermeta($user_id, $key));
else
return get_usermeta($user_id, $key);
}
}

This code defines a new function get_user_meta in case it is not existing already. The new function calls the deprecated function get_usermeta and returns the result so the plugin is working as expected again.

OpenThesaurus

Sunday, April 5th, 2009 in Online

Okay, okay. I can hear you shouting “odl&stale” already, but I did’nt know it until now and can hardly manage to hide my ardor after discovering OpenThesaurus lately. It’s doing, what a thesaurus is doing and that pretty well. An OpenSearch plugin for the browser search bar is available as well, of course.

If I only had known it before writing my diploma thesis…

.htaccess Passwords

Friday, April 3rd, 2009 in Online

For month I’ve been using the wrong password to access my email administration. Strange thing is, I have not discovered this until just now because the web server granted me access all the time. A quick Google search confirmed my suspicion when I found Franz Seidl describing the same behaviour: By default an access control using .htpasswd files is taking only the first eight characters into consideration when checking passwords! So keep this in mind if you are protecting folders of your web server by setting up .htaccess files.

Addendum: adminblogger just pointed out to me, that you can tell htpasswd which algorithm to use when creating a password hash. See a short example by him at pastebin.

Blog Faster

Friday, March 6th, 2009 in Job, Online

Blogging this while doing 160 kph on the left lane of the Autobahn. Brave new world…

TinyMCE broken

Wednesday, September 17th, 2008 in Online, PHP

If WordPress’ visual editor TinyMCE stops working after you have edited the config file tiny_mce_config.php and begins droping error messages telling you “Cannot modify header information – headers already sent”, make sure the config file doesn’t start with a byte-order mark (e. g. 0xEF 0xBB 0xBF). It seems Windows Notepad writes these bytes to the file if you edit and save it with Notepad.

To get TinyMCE running again, get a fresh copy of the config file and overwrite your flawed one with it. If you need to edit the config file try a different editor. WordPad did the job for me. Just to make sure you are not running into the same problem again, check the edited file with a hex editor of your choice and see that it’s not starting with EF BB BF.

WordPress Zooomr Manager

Monday, September 8th, 2008 in Online, PHP, Photos

When Zooomr released it’s API to the public earlier this summer, I hoped someone would use it to add Zooomr support to WordPress. This topic became important again, when my brother began to fill up our precious webspace with more and more photos. I recommended Zooomr to him as a hosting service for his pictures, but since he’s not that much of a techie, I started thinking about an easier way to add Zooomr photos to WordPress articles than looking up the photo URLs by hand at Zooomr. This is how I found Trent Gardner’s great WordPress Flickr Manager – a plugin for just this purpose. Unfortunately the plugin is focussed on Flickr as you can guess by the name.

So I had to rewrite some of the code to match it Zooomr’s API and to my honest surprise it worked quite well. The plugin reached sort of a first stable alpha and although not all features supported by WordPress Flickr Manager are working, the most important of them do. This is a feature matrix of WordPress Zooomr Manager:

Application authentification working
Inserting photos into posts working
JS Lightbox viewer working
Sorting by smart sets working
Managing your photos in WordPress working
Plugin options working
Uploading photos to Zooomr untested
Inserting photos sets untested
JS Highslide viewer untested
Tag search not working
Changing image size buggy
Internationalization unsupported
Labels changed from “Flickr” to “Zooomr” nah

Because I’m a bit short of spare time right now, I’m gonna release the modified plugin in it’s current state. I’d LOVE to see someone improve it or – even better – integrate both Flickr and Zooomr support into Trent’s WordPress Flickr Manager. If you need further information on the modified code or the Zooomr API, I will happily provide it for you as far as I can.

WordPress Zooomr Manager

Download WordPress Zooomr Manager

Even more feeds

Friday, July 25th, 2008 in Online, PHP

Like I promised to my brother, I started working on a news feed for the marketplace of jzr-threewheeler.de. Contrary to my expectations the problem in this case was not so much the caching mechanism I had to implement. I had done that before and could reuse most of the code. What took me so long was the fact, that the marketplace page seems to be created and updated manually – resulting in an chaotic structure of both content and HTML. While containing over 181 000 lines only about 1 200 of them contain more than whitespaces actually. The content doesn’t follow any strict rule either. All this made it quite complex to write a good parser to process the information into a nice (and valid) feed.

Well, I managed to get it done and here it is:
http://threewheeler.feeds.kochs-online.net/jzr-threewheeler.xml

I hadn’t finished the work on this, when Adrian came up with the next task for me. He wanted to have a news feed to follow all recent posts at simsonforum.de. This was a way easier job to accomplish. Message board software does follow strict rules when compiling the pages so parsing them is quite easy because you don’t need to take all kinds of exceptions into account. So a set of simple rules is sufficient to process all the data. Using the board’s search function my PHP script downloads a list of all recently changed threads and generates the feed based on it. Because this produces quite heavy load on both involved servers (the forum’s and mine) results are cached for at least an hour before an update is made – another script using the caching code. :)

You can find this feed here:
http://simsonforum.feeds.kochs-online.net/simsonforum.xml

Lomax in da Feed

Thursday, July 10th, 2008 in Online, PHP

Again I have written a parser to create a RSS feed. Adrian told me about how much he’d appreciate a feed to follow all newly advertised Lomax kit cars over at the second-hand market of lomax-club.de. As is so often the case with pre-web-2.0 sites there wasn’t a feed available, so I sat down and made one. Et voilà – there it is: http://lomax.feeds.kochs-online.net/lomax.xml

I tried to make it as compliant as possible, but lacking most of the sellers/buyers e-mail addresses and being reluctant to publish mine to all those spambots out there, the feed isn’t completely valid. Maybe I’ll come up with a solution to that problem someday.

An optional “items=” URI query string may be used to define the maximum number of feed entries to be generated.

Frollein Kuttner’s Feed

Saturday, July 5th, 2008 in Online, PHP, TV

Being a longtime fan of Sarah Kuttner, I was happy to hear she’s producing a new little show these days. The announcement of “Kuttners Kleinanzeigen” was some weeks ago and I almost forgot until yesterday evening, so I checked her site to see the exact air dates of her show. Being there I visited the news section and thought about reading it more regularly. So I wanted to add the news feed to my FeedReader, but I had to discover there was no feed available.

Well, now there is. I wrote a little parser that converts all news entries into a nice, (almost) well-formed RSS 2.0 feed. You can find it under http://kuttner.feeds.kochs-online.net/kuttner.xml. Using the optional query string “items=” you can specify how many of the latest news items the feed should contain. Default is 10.

Multiple blogs with a single WordPress installation

Thursday, May 8th, 2008 in Online, PHP

When I started setting up the blogs some days ago, I began to create subdomains and subdirectories on the server where I could install WordPress. Soon I discovered, how complicated and prone to errors this procedure can be and started to think about alternatives allowing me to run several separate blogs while administrating and maintaining only a single software installation. You can find some more or less complex hacks for this floating around the net. In addition there exists a special multi user/multi blog version of WordPress called WordPress µ, but it seems it is turned mostly towards very large projects and uses a number of modifications of the original variant for this purpose. On the other hand there is an approach by Strider which is called Virtual Multiblog and looks quite feasible. However this looks a bit intricately at first glance because it seems to require an additional WordPress plugin.

Finally I discovered a very elegant way by myself: Because WordPress stores all settings of a blog – including articles, comments and users – in the MySQL tables defined in the file wp-config.php, it would be sufficient to use different configuration files depending on the used subdomain. So I modified the wp-config.php to simply evaluate the used subdomain and load a configuration based on the result. Which looks like this:

<?php
if ($_SERVER['SERVER_NAME'] == 'blog1.example.com')
{
require('wp-config.blog1.php');
}
else if ($_SERVER['SERVER_NAME'] == 'blog2.example.com')
{
require('wp-config.blog2.php');
}
?>

The files wp-config.blog1.php and wp-config.blog2.php are just standard WordPress configuration scripts without a single line of extra code. Using different prefixes for the MySQL tables it even would be sufficient to have a single database to store all blogs. As simple as it is, as low-maintenance it is too, because WordPress updates don’t overwrite the new wp-config.php or the newly created configuration files. At the same time all blogs benefit from the update, of course.

[Update: It just caught my eye, that you might run into difficulties if you are running multiple blogs with the same plugin. If an upgrade of that plugin requires an update of the plugin's database table, you have to pay attention to update all of those tables (for every blog using the plugin)!]