Fix Contact Form 7 “Failed to send your message. Please try later or contact administrator by other way.”

I updated the Contact From 7 plugin I’m using on this site and then started receiving “Failed to send your message. Please try later or contact administrator by other way.” errors from it. I tried the only fix I could find on the internet which was to change the from e-mail to the same domain as the website, but it didn’t help.

After looking at the code I managed to find what was causing my error, it was the WP-Super Cache plugin I’m using. The contact form plugin generates a unique token for each person who submits the form, presumably to stop CSRF attacks, which was being cached by WP-Super Cache which in turn caused the token to no longer be unique or valid.

Adding /contact/ to the excluded strings in the Advanced section of WP-Super Cache settings solved the problem for me. Hopefully this will help someone else who gets stuck by this error.

How to install Aptana Studio 3 on Ubuntu 11.10 (Oneiric)

These instructions are for installing the standalone version of Aptana Studio 3.

1. Install Sun Java – Aptana Studio doesn’t currently work with OpenJDK:

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

2. Download & install xulrunner – Ubuntu 11.10 doesn’t include xulrunner so it must be downloaded.

If you are using Ubuntu 64 bit use:

wget -O xulrunner.deb http://launchpadlibrarian.net/70321329/xulrunner-1.9.2_1.9.2.17%2Bbuild3%2Bnobinonly-0ubuntu1_amd64.deb
sudo dpkg -i xulrunner.deb

If you are using Ubuntu 32 bit use:

wget -O xulrunner.deb http://launchpadlibrarian.net/70321863/xulrunner-1.9.2_1.9.2.17%2Bbuild3%2Bnobinonly-0ubuntu1_i386.deb
sudo dpkg -i xulrunner.deb

3. Download the Standalone version of Aptana Studio 3 from the Aptana Studio website.

4. Unzip it to /opt/aptana-studio-3:

sudo unzip [name of Aptana Studio ZIP file here].zip -d /opt
sudo mv /opt/Aptana\ Studio\ 3 /opt/aptana-studio-3

5. Install the menu item:

wget http://www.samclarke.com/wp-content/uploads/2011/11/AptanaStudio.desktop
sudo mv AptanaStudio.desktop /usr/share/applications/AptanaStudio.desktop

That’s it, Aptana Studio 3 should now be installed and ready to use. You may need to log out and back in it to show in the menu.

Adding custom commands to SCEditor

For instructions on setting up SCEditor, see here. Custom command support requires SCEditor version 1.2.4+.

Adding Custom Command

SCEditor has a function called setCommand which updates a command if it already exists or adds it if it doesn’t. setCommand must be called before the editor is initialised otherwise the command may not show in the editors toolbar.

setCommand parameters:
Name (string): The name of the command, should be lower-case and not contain any spaces.
Exec (string or function): Should be a function which will be called when the command is clicked or a string which will be passed to the browsers built-in execCommand function.
Tooltip (string): The commands tooltip text
Keypress: Unless the command needs to handle keypress events, omit this parameter. For an example of keypress handler see the emoticon command.

Continue reading

Incapsula vs. CloudFlare performance

To see how Incapsula and CloudFlare compared performance wise I’ve set up two identical pages, one going through Incapsula and the other through CloudFlare, and tested them with various online tools.

From my tests CloudFlare appears to be much faster for the first few resources, but the last few resources seem take much longer to load (See Pingdom results for an example). Incapsula is slightly slower but unlike CloudFlare it’s speed is much more consistent with all the resources leading to very similar load times. Continue reading

Install APC with XAMPP on Linux

If you don’t already have the XAMPP development files installed you must install them first. The XAMPP development files can be downloaded from here.

Alternatively to install the XAMPP development files run the following commands:

wget -O xampp-dev-files.tar.gz http://www.apachefriends.org/download.php?xampp-linux-devel-1.7.7.tar.gz
sudo tar xvfz xampp-dev-files.tar.gz -C /opt

Note: Change 1.7.7 in the above wget command to the latest version listed on the XAMPP website linked above. Continue reading

Incapsula Review

Incapsula, like CloudFlare, is free & paid for service which claims to enhance the security of a website while boosting its performance at the same time.

I’ve been testing Incapsula to see how good it is and how it compares to CloudFlare (which I’m currently using). This review is of the new release of Incapsula which was released on the 21 September 2011.

Setup

Setup with Incapsula was straightforward and only took about 15 minutes from start to finish, most of which was waiting for Incapsula to notice the DNS changes. CloudFlare was slightly faster at noticing the DNS changes but not by much and as this is only done once it shouldn’t really matter.

The Incapsula control panel is easy to use and looks good with plenty of options available.
Continue reading

SBBCodeParser – PHP BBCode parser class

SBBCodeParser is a simple PHP BBCode parser class which makes it easy to add your own BBCodes.

SBBCodeParser is licensed under the LGPL and the source code is available on GitHub.

Example usage:

$parser = new SBBCodeParser_Document();
$parser->add_emoticons(array(
	':)' => 'http://localhost/Classes/SCEditor-punbb/punbb-1.3.5/img/smilies/smile.png',
	'=)' => 'http://localhost/Classes/SCEditor-punbb/punbb-1.3.5/img/smilies/smile.png'
));
echo $parser->parse('This should be [b]bold[/b] and this should be [i]italic[/i]')
	->detect_links()
	->detect_emails()
	->detect_emoticons()
	->get_html();

Example of adding a custom BBCode:

$bbcode = new SBBCodeParser_BBCode('youtube', function($content, $attribs)
{
    if(substr($content, 0, 23) === 'http://www.youtube.com/')
        $uri = $content;
    else
        $uri = 'http://www.youtube.com/v/' . $content;
    return '<iframe width="480" height="390" src="' . $uri . '" frameborder="0"></iframe>';
}, SBBCodeParser_BBCode::BLOCK_TAG, false, array(), array('text_node'), SBBCodeParser_BBCode::AUTO_DETECT_EXCLUDE_ALL);
$parser->add_bbcode($bbcode);

Continue reading