Running a remote backup of cPanel automatically

I’ve been looking for a way to automatically backup individual cPanel accounts to a remote server that don’t necessarily have root WHM access. In particular, I want the MySQL databases, but I would also like to get entire site backups if possible.

I’ve found a few posts about it that I’m going to have to have an experiment with when I get a chance and see what works. For reference though, and if anyone else is looking for this, the sites that look the most promising are:

Installing Drupal on Windows Server 2003 – Relevant Links

Recently I have needed to setup a Windows 2003 IIS server to run Drupal, the catch though is that it already runs an ASP.NET website and does not have MySQL, PHP, or even FastCGI installed. So, it must not affect the existing website at all. Working on a development server, I’ve been trying to get this to behave correctly. It is out of my area of expertise, so I’ve been doing a lot of reading up on it. The links I’ve used are mostly all below, mainly for my future reference and for anyone else that may need to do the same:

The easiest way to set Drupal up on Windows should be with Microsoft’s installer. It uses their WebMatrix with the Web Platform Installer and looks like it should automate the process and configure everything that needs to be configured. The problem with it though is that it uses IIS Express, which can’t run alongside IIS, and the installer cannot run with IIS, which means I can’t use it for this situation.

So far, I’ve tried the IIS Aid PHP installer, which seems to work for the most part, however, I’m having FastCGI errors left right and centre with it crashing constantly. Unfortunately the IIS Aid installer doesn’t seem to work when using ISAPI instead of FastCGI, so I’m not up to installing and configuring PHP manually using FastCGI, and if it’s still unstable, ISAPI.

Another option is to look at running Apache on a different port to IIS, but I would rather not go down this route if I can avoid it.

It’s a real pain. If you have any experience with this, tips or advice would be appreciated!

10 Great Creative Commons Coffee Cup Photos

I recently had to find the perfect image of a coffee cup for use on a client website, and Creative Commons images were approved for use, so I did some hunting around, both on stock photo websites and searching through Creative Commons images on Flickr.

Some of the Creative Commons images on Flickr are fantastic! Here is my top 10 (in no particular order), click on the images to check them out full size at Flickr and check the Creative Commons license:

Quality Coffee

“Quality Coffee” by sh0dan.

My coffee's design for the day at Fluid

“My coffee’s design for the day at Fluid” by ~ggvic~

Coffee

“Coffee” by Rob Qld

Used coffee mug

“Used coffee mug” by odolphie

Fresh Cup

“Fresh Cup” by mikecpeck

Tea Cup

“Tea Cup” by *saxon*

Golden Gate

“Golden Gate” by CarbonNYC

Coffee

“Coffee” by mcveja

A moon in my coffee

“A moon in my coffee” by fdecomite

Coffee...mmmm

“Coffee…mmmm” by L. Marie

Internet Explorer Truncates Long CSS Files

I came across an interesting quirk in Internet Explorer a couple of days ago whilst working on a project for a client.

There is a section on their website that has an extensive set of stylesheets that is around 3,500 lines long. Combined with the stylesheets for the rest of the website, the total is about 6,500 lines.

The design was all finished and looked great in Firefox, Chrome, Opera, IE 7 and IE 8. However, then I did up the set of styles I mentioned that ended up totalling 3,500 lines. Due to the way I lay out my stylesheets, these started at about line 2,000. Which meant about 1,000 lines were after them.

While I’m working on something new I test in Firefox with Firebug and then once I’m finished I adjust for IE. So all of a sudden when I tested in IE 7 and 8, they are not displaying things correctly, including things in the design that were working previously. Using IE’s built in developer tools I was able to see that there were stylesheets simply not being applied to things that they should have been after about the 4,500 – 5,000 line mark. The entire stylsheet was loaded though and could be viewed.

I began tweaking things in the IE specific stylesheet since I couldn’t get it to work by editing the regular stylesheet. Once I realised that I could copy things directly from the main stylesheet into the IE one and it worked without tweaking, I started to think something odd was going on.

Cutting the extra 3,500 lines out put the site back to normal in IE, except for what those things affected.

If I put those lines in a separate stylesheet, everything worked perfectly fine again.

So it seems to me that for some reason IE just will not read more than around 4,500 to 5,000 lines in a stylesheet. It could perhaps also be total characters, however I didn’t test to find at exactly what point it stopped reading so I can’t be sure.  Fortunately, simply adding in an extra stylesheet did solve the problem, and given the nature of the extra CSS, it probably should have been done that way in the first place so that it could be loaded solely on the pages that actually need it. It should be noted that the total lines are still the same, they are just split between two stylesheets now, one of which is only loaded on certain pages.

I did a quick search for this but didn’t really come up with anything similar elsewhere, so if you have had a similar issue, I would love to hear about it!

It seemed to be consistently about the same place in both IE7 and IE8, so hopefully it won’t find it’s way into IE9.

John Bortolin Photographer

John Bortolin is a photographer based in Lennox Head that specialises in wedding photography as well as portraiture and landscapes. He looks after the photography for weddings all over the Northern Rivers region including Byron Bay, Ballina and Lismore. He came to me at TerraMedia with an existing static website that had been intended as an online showcase of his photography.

John Bortolin Wedding Photography
John Bortolin Wedding Photography Home Page

I revamped the website for him, cleaned up some of the design issues and produced a gallery system that is clean and efficient, showcasing his landscape, portrait and wedding photographs.

Continue reading John Bortolin Photographer

My Work Area

Over at Onextrapixel they have just done a showcase of the work areas of 88 designers. I was invited to include my work area, however, it was Good Friday that I received the invitation and being the Easter long weekend, I didn’t really get my act together in time. However, since I took a photo anyway, I figured I might as well put it up here.

My primary work area:

My Work Area
Where most of it happens.

Most of the work areas shown on Onextrapixel seem to me to have been tidied up before hand, this is mine though, how it is 90% of the time. I do every few weeks have a tidy up, but for the most part this is it, filing and everything.

The machines you see are as follows:

Macbook Pro

This goes everywhere with me and probably gets more use than the workstations! I love it and it is great for most purposes. It is a 15″ Unibody Macbook Pro with an Intel 2.4ghz Core 2 Duo and 4gb of RAM.

Mac Pro

My favourite machine of the lot and now my primary workstation, this is a beautiful computer to work on. It is an 8 core machine with 2x 2.8ghz Intel Xeon CPU’s with 8gb of ECC Registered Memory. The screen I’m using for it is a 23″ Samsung (beautiful screen).

This is the beast that does all the heavy lifting. All the big graphics jobs are done on this machine. It also has a Logitech Di Novo Keyboard for Mac (much nicer than the standard Apple wireless keyboards and feels a lot like the Macbook Pro keyboards) and Apple Magic Mouse (multi-touch for a desktop computer = awesome), so it’s just like using a Macbook Pro, but with more power than you know what to do with.

Windows 7

The third computer you see is my old workstation which is now running Windows 7. I haven’t gotten rid of it yet simply because it is still a nice computer. It’s running a 2.4ghz Intel Core 2 Quad (Q6600 from memory) with 4gb of RAM, so it is still quite fast, even faster now with Windows 7. It’s complimented with dual 19″ Samsung LCDs.

I use it primarily for email management and testing on Windows. I do run Windows virtual machines on both my Mac’s, but sometimes it’s just quicker and easier to use this computer. It is also where most of the games are played (when I occasionally have time to play them).

What else is there?

Hidden in the recesses under the desk is also a Thecus N4100Pro NAS which handles data and most of the backups for all the computers. You’ll also see I have lots of filing and an Epson Multi-Function Printer. I did have a whiteboard, but I honestly don’t know where it is. I put it somewhere before I went on holidays over Christmas. It’s now MIA. Kicking around on the desk somewhere is an 8 port Ethernet switch, 4 port Ethernet Gateway and an Airport Express. There are cables everywhere beneath the desk – it’s a bit of a nightmare, especially considering there is also a NAS and a few UPS’s down there!

So that’s pretty much it, my work area. Ideally I want to put in another desk and move the Mac Pro to it and set it up with a better drawing space. As you can see my current drawing area is fairly limited and requires me to move keyboards before I can do any drawing.

I do have to admit, I like the idea of a minimalist style workspace, but there is just no chance of it happening, there is just too much that has to go somewhere in my work area!

Where else do I work?

One of my favourite places to work is actually on the sofa on my upstairs balcony. I love it up there. I take the laptop up there for a few hours at least once a day. It’s an excellent change of pace and results in some excellent design ideas. I’m thinking about starting a YouTube channel for TerraMedia which will probably be filmed on my balcony.

What do I do with all those computers?

As you may know, I am primarily a web designer. I own TerraMedia, a web design and development business where I specialise in Drupal websites and Drupal theming. My clients include small, sole trader businesses such as myself through to medium sized companies and online enterprises including e-commerce websites and online communities.

You can find me on Twitter at the following accounts:

Or you can find my on my other websites at:

Finding The Path To Your Drupal Theme

Ever needed to reference a file in your Drupal theme? For example, an image from your page.tpl.php file, or a JavaScript file?

You can hard code the path, which might be something like:

/sites/all/themes/mytheme/images/myimage.jpg

Or, with a little bit of PHP, you can use Drupal’s built in path_to_theme() function. This function will print out the path to your Drupal theme from the root directory.

So, in your theme you might have this image, but instead of writing:

<img src=”/sites/all/themes/mytheme/images/myimage.jpg” alt=”My Awesome Image” />

You could write:

<img src=”/<?php print path_to_theme(); ?>/images/myimage.jpg” alt=”My Awesome Image” />

At first glance it is slightly longer and might seem like more effort to do. Think of it a bit differently though. What if you want to rename your theme, or use your theme on a different domain name? You will need to change the hardcoded path. By using Drupal’s path_to_theme() function, it will dynamically figure out the path to your theme directory for you.

We can then take this a bit further with Drupal’s base_path() function. This particular function returns the path to the base Drupal installation. If you have it installed in the root directory of your hosting account, then this will simply be a /.

The real benefit of this is if your Drupal installation is in a different directory. For example, /drupal. If this is the case, then your hard coded path would be /drupal/sites/all/themes/mytheme/images/myimage.jpg the path_to_theme() function will still only return /sites/all/themes/mytheme though, and the browser will not be able to find your image. The reason for this is that it only determines the path from the base installation directory of Drupal. So, to make sure your theme is truly dynamic and capable of dealing with this, you would use something like this:

<img src=”<?php print base_path() . path_to_theme(); ?>/images/myimage.jpg” alt=”My Awesome Image” />

Now if you have Drupal installed in a sub-directory called Drupal, this would actually return the full path we need: /drupal/sites/all/themes/mytheme

One thing to remember if you use this is that the path_to_theme() function doesn’t put in a trailing / or start off with a / so you will need to put these in before adding in the rest of your files location. Comparatively though, base_path() does add a / both before and after the path. So if you use it, you will not need to prefix it with a /.

This works in Drupal 5 and 6, and I believe is going to continue to function the same way in Drupal 7, so your themes will be all set to work on any server without needing to adjust the file paths. Give it a try!

You can also have a look at these functions in the Drupal API documentation:

Applying Patches to Drupal or Modules on Mac OS X

I’ve had to run a number of patches to Drupal modules before, and I’ve always done them on my Windows machine simply because that is what has the most instructions available to do so. At the moment though I am away on holidays and only have my Macbook Pro, so when I needed to run a patch I debated going to the effort of doing it through a Windows virtual machine that isn’t set up for it, or set up Eclipse and run it through their software. After much debating, I decided to look up the instructions again and see if there was a recommendation. While I was hunting around, I noticed two very, very useful things:

  1. Apple’s Xcode suite allows you to run Drupal patches.
  2. You can patch files using the OS X terminal without any need to install special software such as what I needed to do to run patches through the Windows Command Prompt. You don’t even need to have Xcode installed!

I already have Apple Xcode, as does every Mac user (if they choose to install it from their OS X disc), so that seemed like it would potentially be the easiest option, then I saw the instructions to patch a Drupal module using the OS X Terminal. It is so easy I can’t believe I didn’t start patching on my Mac sooner!

The process to patch a Drupal module on Mac

  1. Place both the original module file and the patch in the same folder.
  2. Make sure that they have the same name, with different extensions, so you would need my_module.patch and my_module.module.
  3. Open up the Terminal application. Either search for Terminal in Spotlight, or go to Applications > Utilities > Terminal.
  4. Navigate to the folder containing your files using the Terminal cd command. By default Terminal will start in your user directory, so if your files are in a folder called patch/my_module inside your user directory, you would type: cd patch/my_module. A little trick here to save yourself some trouble is just type cd and then drag the folder into the Terminal window. OS X will auto-fill the folder path for you.
  5. Run the patch using the patch command: patch < my_module.patch

That’s it! Simple as that.

If you would like to take a back up of the original patch file, type: patch -b < my_module.patch and a backup file will be created for you entitled my_module.module.orig

If you are patching Drupal core, the process is slightly different, you need to use the -p0 attribute to stop patch from asking you what file to patch, so you would do this as: patch -p0 < my_module.patch

Those are probably the main things you’ll use, but for more information, here are some other references:

One other thing to note is that if your .patch and .module files don’t have the same name, then Terminal does sometimes have issues with it. I’m not sure why exactly.

Hope that helps! If you’ve got any other tips for patching on OS X I’d love to hear them!

Placing Adsense After Your First WordPress Post

Google Adsense is a great way to make some money off of your blog, and by placing your code in a couple of key places in your template files, you can have it automatically displayed on all of your blog posts. One thing to keep in mind though is that you can only show 3 ads per page, any more than that and in most browsers an empty space will be left, which is to some extent ok, but in other browsers it can appear as a broken iframe or image. While an empty space isn’t ideal, it can be acceptable, a broken section on your site really isn’t.

It’s for this reason that most people will set up their template to only display Adsense code on the first post shown on each page where multiple posts are displayed. For example on your index page, category pages, tag pages and archive pages.

So to ensure that your Adsense code only displays once you need a way to make sure that when WordPress loops through each post, there is some way for it to figure out whether or not it’s the first post. Joe over at joehayes.org has written a great post about doing this.

Somewhere before the start of the WordPress loop, you need a base way to count. Joe has done this by placing the following code:

<?php $count = 1; ?>

Before the WordPress loop which starts off with:

<?php if (have_posts())

Then inside the content section of the loop which starts off with:

<?php the_content

You need to decide whereabouts you are going to put your Adsense code. Paste it in somewhere, this could be before or after the post content, or after the meta information, or anywhere else that be suit your particular template.

Now, just before the start of your Adsense code you need a way to check the number of posts. We’ll use some PHP to check the $count number that we set earlier.

<?php if ($count == 1) : ?>

This checks to make sure it is still 1. If it is, then your Adsense code will be displayed. If not then it won’t be.

Directly after your Adsense code we then need a way to make sure that the other posts don’t also appear as number 1.

<?php endif; $count++; ?>

This section of PHP tells WordPress to add 1 to the counter. So the next time WordPress runs through the loop, it will be a 2 instead, and it will go 1 higher for each post, so only the first post will appear as 1, thus only the first post will show the Adsense code.

It’s pretty simple but it does the trick very well!

If you wanted to display 2 or 3 ads, one on each of the first 2 or 3 pages, you could simply change the PHP around a little bit.

<?php if ($count <= 3) : ?>

The above snippet for example tells WordPress that if the count number is 3 or lower, than it should display the Adsense code with only 2 minor changes to the original code.