Multiple FTP users in Plesk 9

By now, Plesk is supposed to have built in support for creating multiple FTP users through the web interface, but it doesn’t seem to have materialised. So for the mean time, SSH is still the way forward:

Create ftp user with their own home directory:

Set the ftp user’s password:

Add user to group psacln:

Change folder permissions for home directory:

Change ownership to user and group:

Set execute permission on the httpdocs folder for the domain:

At this point you have a valid FTP user who can connect. But only to their own folder. Now I want users with FTP write access to httpdocs so I can give 3rd party support access on occasion and later revoke it without having to change my master password. Also, all their actions will be logged as their user, so we have a data trail in case of things going pear shaped.This is as far as Parallels’ guide goes, so we have to do a couple more steps:

Set the user’s home directory to the webroot:

Grant write permissions to the group on the webroot:

And we are done!

Where $HTTPD_VHOSTS_D is your vhosts path (typically /var/www/vhosts on the CentOS 5 boxes I’ve used) and USER_NAME is your chosen… errr, wossitcalled…

‘/some/location’ should be a non public access directory, e.g. /var/www/vhosts/your_domain/web_users/USER_NAME

These intstructions are tested on CentOS 5 / Plesk 9. They should work for other *nix flavours, but as with everything on t’net, excercise caution, and on your own head be it.

Checking multiple XML files for errors with Shell script and PHP

A joomla site I work on is throwing an XML error, with, of course, no information on what file is throwing the error.There are 1260 XML files on the server, so I’m not about to check them all by hand.

The first task is to locate and list all the XML files in the site in a text file:

I then tried to write a script to process each line of that file (based on ) and use xmllint to check the file, and again output the results to a file. Unfortunately, xmllint doesn’t seem to like appending with >> and while you can specify an output file, I don’t want 1260 results files either! So I wrote a php script to do the job instead.

Note that in all these snippets, you will need to replace the paths and domains with yours, of course. So, this worked nicely. Except that most of the XML files don’t have a DTD, and those that do seem to completely ignore it, so everything comes out as invalid. Just… great. I love working with Joomla.

Bi-directional AJAX Loading Icon

Just got this idea in my head for a loading icon that spins in two directions at once, based on an exclamation mark, so I thought I’d try it:

The idea seems to work, but it could do with some tweaking. But enough dicking around, I have more important things to do.
I tried to post the file for people to play around with, but Posterous doesn’t accept ZIP files (security risk) and cleverly converts PSDs to images (cunning indeed). So you will just have to live without. Make your own damn annoying spinning thing why don’t you?

Oh go on, here it is:

Tweet and Like This for your site

Just as Posterous has Tweet and Like buttons on each post, a client asked me to do the same for his site yesterday.


Getting all twittered up wasn’t too hard – I started with John Resig’s Easy ‘Retweet’ Button

Nomenclature not withstanding (it’s not exactly ‘retweeting’, more ‘tweet this’) I found it to be a pretty good guide, highly customisable, and it was up and running before I left the Brixton office.


Facebook Like buttons are a bit more work, and I haven’t finished them yet, as they require ‘setting up your page as a Facebook Application’ – I’ve done everything on the client site end, which required a lot of reconfiguring of the way the site was moddled, which is OK as its now much closer to the MVC model, and now just need to deal with the Facebook end. Arse about tit perhaps, but the Facebook instructions neglected to mention the minor of matter of making your site an FB app – or how to do it as far as I have found yet. Well that’s one of the next things on the list.

I am going for the more complex <fb:like> XFBML tag/Javascrip route over the iFrame method for two reasons:

1)      Javascript is more powerful, flexible and tidier.

2)      iFrames just SUCK. Once upon a time they were a clever and necessary if messy way of achieving some nice tricks. Today they are like the appendix, the coccyx and nipples on men.


Here are some links that have gotten me this far:

Note, I’m not working on a wordpress site, but this was the first page I saw that pointed out that <fb:like> XFBML  “requires that your page/post make a call to the JavaScript SDK and that your page be set up as a Facebook application (quite easy)” and then goes on to show you EXACTLY HOW TO DO IT! Yeah, that’s the way we like it, uh huh, uh huh…

[UPDATE 1800 4-6-2010]
Well, the application setup was incredibly  simple, and just dropping in the FB App ID (and adding a <div id=”fb-root”></div> tag to the end of the page, which FB didn’t  think important enough to mention!) it works. Now I need to hack it to display the way I want it to! 


[UPDATE 2000 4-6-2010]
Ah. No, it doesn’t work – it just throws an error with no debug info. That sucks.
And you don’t stand a chance in hell of restyling it – even the Javascript method calls up an iFrame, meaning you are unable to affect it’s appearence with either JS or CSS. That also sucks.


[UPDATE 1650 21-6-2010]
First time back on this particular client’s site since, and it appears things are actually working well. It does occasionally throw an unspecified error, as I first saw, making me think it was crocked on my first test, but you will get AJAX communication errors from time to time whatever you are doing.
Now I just had to make it usable – we don’t have room in the site design to have this massive Facebook like widget eating virtual real estate, and as noted before, we can’t control the iFrame contents using CSS or Js.

BUT we can control the iFrame container. By placing the Facebook widget in a div, we can shrink that div to just the size of the button, and then using the :hover pseudoclass increase it’s size on mouseover.


What is it with documentation? I’m a clever guy, I write tech docs myself, and while I’m not a university trained programmer I’m not a bad one. But SO many tech docs sketch barest bones on very specific tasks, miss vital instructions that could often be provided with a simple link where they are more complex than space permits, and don’t provide examples!

Speaking of which, I hope to add some code examples of both these methods later, as well as my Like and Tweet PSD files, free to use, modify and redistribute.

Cutting the Stream: Counting and stripping tags cont.

As I continue to work on truncating long activity stream posts, there aremore and more steps that need to be taken to clean up the code.

I don’t have time to fully explain everything I have done lately, so this iscurrently more a bunch of useful links and the current function and classesto point in the right direction.

First off, with some activities coming from the forum, they have BBCode inthem which is not parsed by the activity stream. Updating thestrip_html_tags() function to remove BBCode tags too is easy:

Argh! Knackernuts! While I get on to Posterous about the continued issue with object and embed in markdown, get the code from

The function now also replaces inserts html line breaks before newline characters with the php nl2br() function after all tags have been stripped. The function name is perhaps becoming inaccurate, but the function is doing what I demand of it!

I also had some issues getting html_count class working in production, where it had been fine in testing.…

The issues here was that html_count is designed to parse the contents of an external file, not a string. Now, I can call an individual activity as an external file, but this requires post data to be sent.Wez Furlong’s do_post_request function set me on the track to solving that one:

However, it seemed a little (understatement of the year) inefficient to be generating an external file and parsing that for each activity in a stream (which can get very long when you ‘show older posts’ a few times), particularly when all that data being parsed is already in my hands at that point, so html_count needed tweaking to be able to handle strings and files – there are now two classes: string_html_tag_count and file_html_tag_count. These could easily be wrapped into one class with a switch to select which variant you wished to use. I just haven’t spent the extra few minutes doing that, as this is all taking far too long as is!