Archive for the 'Advice' Category

Plesk Backup Error: Specified file is not accessible

After upgrading my Plesk install past 8.1.1, I encountered a problem with the builtin backup utility. When attempting to create a new backup (either locally or to an FTP repository), I would almost instantly be handed back the error:

Unable to create backup session: Specified file is not accessible

I googled around and found a couple of results, including a support forum that actually had the answer to my problem burried back on the second page.

For whatever reason, Plesk loses the ability to write to its temporary directory, where all backups are held until they are completed (even for FTP destinations). I was easily able to solve this problem by (as root):

chown -R psaadm:psaadm /var/lib/psa/dumps

Note that the original author of the suggestion I used said to chmod 777 the files, but this proved to be unnecessary. I saw that the parent directory was owned by psaadm, and it just made sense that the dumps directory would need to be as well.

In any case, it worked for me. Hope this helps someone…

Modifying Allowed Upload Types in Wordpress

Several times recently in #wordpress, I’ve seen people asking how they could modify the list of allowed file types used in the file uploader on the Write Post page.

Since this information isn’t readily available (apparently) and to a lesser degree because I’m tired of not being able to find my previous code (causing me to re-type it all each time), I thought I’d throw together another quick WordPress hack guide.

Introduction

When you attempt to upload a file in WordPress (2.0+ I believe) that is not in the default list of acceptable file types1, you will receive the following error:

WordPress File Upload Error

As of WordPress 2.2, there are 35 allowed file types configured in the default install. While there’s no admin-based tool for editing this list (nor any plugins that I’m aware of), it’s not at all difficult to add your own…

The Code

Upload filetypes are checked by the function wp_check_filetype in wp-includes/functions.php (around line 1,000 in my current copy of trunk). Looking at the code, we see that the default array is passed into the upload_mimes filter, allowing you to easily add and remove types at will using a quick plugin hook.

So how do we do it? Well, first you need to add a new plugin hook. In your theme’s functions.php file, add this line:

[php]
add_filter(’upload_mimes’, ‘custom_upload_mimes’);
[/php]

You can, of course, replace custom_upload_mimes with your own preferred function name. Just make sure it’s something unique that ideally won’t cause any naming conflicts later on2.

Now we’ve got a hook that tells WordPress to take the array of file types passed into the upload_mimes hook and hand it to the function custom_upload_mimes. Great, but where’s our function?

No problem, I’ve got it all ready for you. Open back up your theme’s functions.php file and toss in this code:

[php]
function custom_upload_mimes ( $existing_mimes=array() ) {

// add your ext => mime to the array
$existing_mimes['extension'] = ‘mime/type’;

// add as many as you like

// and return the new full result
return $existing_mimes;

}
[/php]

Note that the function accepts the $existing_mimes array, adds a new file type (with the extension “extension” and of the mime type “mime/type”), and then returns the whole array.

Replace extension with your extension (no period before it, just the textual extension) and then Google to find out its mime type3.

Add as many new types as you like, simply by copying the example line and filling in your values. Also, make sure you name the function the same thing you used in the hook, assuming you don’t like my convention. Save your new functions.php file and you’re good to go!

Removing Existing Types

What if you want to remove an existing allowed type, instead of adding your own new type? Well, that’s even easier!

Replace the line $existing_mimes['extension'] = ‘mime/type’; with unset( $existing_mimes['extension'] ) and you’re done. For example, to prevent users from uploading .exe files, you would use:

[php]
unset( $existing_mimes['exe'] );
[/php]

Good luck, hope this helps!

  1. For example, Microsoft Installer files are not allowed by default, so track down an .msi file and try to upload it for a quick test. [back]
  2. I like to use the prefix ‘custom_’ simply because it’s easy to tell later on that this is a custom modification. [back]
  3. Googling for “.zip mime type”, for example, should give you any number of sites listing a whole slew of mime types. Yours should be in the same <category>/<type> format as the others. Zip is “application/zip”. [back]

A New File Server Begins…

Bought a new LSI MegaRaid 6-port SATA adapter last night, now I just need to build a machine around it1.

The only slight downside is that the SATA adapter requires a 64-bit bus, which is going to make the rest of the box slightly more pricey than I’d have liked. Oh well, I guess it’s about time I bit the bullet and made a decent box anyway…

Hell, if I go far enough, I may be able to consolidate the domain controller, SQL 2005 (which would, eventually move into a VM), and the Virtual Server 2005 R2 boxes. If they were able to run on some (probably dual-Xeon) box together, I’d have quite a bit of extra hardware laying around to play with.

This is really the part I hate. Now I’ve got to piece together parts from all across the ‘net, looking for the best performance yet the best deal, while trying to balance the desire to get everything from one retailer.

If you’ve got any particular recommendations on where I should head with this project, feel free to chime in. I’m always open to the opinions of greater nerds who watch hardware performance tests like the true geeks they are…

  1. Sure, some would say I’m building in the wrong direction, but nerts to them! [back]

The “Grid” is Falling….The “Grid” is Falling

I happened to find this Digg story in the upcoming entries. The “Grid” is Falling….The “Grid” is Falling is about the crappy level of service provided by the new Media Temple “Grid” service.

Since I’ve been thoroughly displeased with the service I’ve had at (mt) over the past several months, I encourage you all to digg that story… for me, please! Not only is their hosting service absolutely atrocious, but their customer service isn’t much better.

For example: Last night all my sites were down. Instant reject for all connections. I open a “Service down or not responding” ticket (which is buried under what’s effectively a “Miscellaneous” category in their web system). At 9:30 this morning they finally respond with a message to the effect of “Yeah, it was a planned downtime.” How exactly was it planned? You didn’t inform any of your customers. The only way I found out about it was by reading the “Internal Incident” report I was linked to by a support rep…

As I said, horrible service. Don’t even think about getting a “grid” server from (mt), you’ll regret it. Please digg the story above, and let me know about any hosting recommendations…

A Bin or a Bucket?

I need a name consultation from anyone who happens to see this post in the near future…

You’re dumping a bunch of random stuff somewhere. Is it a bin or a bucket?