Category Archives: Mystery Solved

[solved] Gravity Forms with Javascript Validation

Gravity Forms (, without a doubt is one of the best WordPress forms plugin out there, I have been using it since it was launched and is a brilliant tool and I have it in use on literally hundreds of web sites.

However, recently I have had the need to put javascript validation on some forms and unfortunately, Gravity forms does not natively support it.

When I contacted Gravity Support to ask about javascript validation, they basically told me its not supported and I was on my own.

So below, is some jquery code I have scrapped together to get it working.


Just assume that the form is Form ID is 7, the rest should be self explanatory.

The code can be put anywhere you like as long as it’s before the Gravity Form function call.

<!-- For Gravity Forms Validation Top Form -->
<script src="//" type="text/javascript"></script>
jQuery(document).ready(function() {
jQuery("#gform_submit_button_7").click(function() {
return GravityFormValidation_7(gform_7);

function GravityFormValidation_7(Form){

if (Form.input_7_1_3.value == “”){
alert(“Please enter your Name”);
return (false);

if (Form.input_7_2.value == “”){
alert(“Please enter your Phone Number”);
return (false);

if (Form.input_7_4.value == “”){
alert(“Please enter your Email Address.”);
return (false);


[solved] How to Delete Plesk Backups

The following command can be used to delete all the backup files in a plesk server.

cd /var/lib/psa/dumps/
rm -rf *

When might you need to do this?
You might find that your disk runs out of space due to the many automated plesk backups that are run and when you check /var/lib it will show 100% being used, like this…


[SOLVED] Issues with PureFTPD with TLS/SSL on Cpanel + ASL

On a couple of Cpanel servers today I was having awful issues getting TLS/SSL to work through pureFTPD in conjunction with the mighty ASL firewall. I found the solution in the end and it was relatively painless.

So, you are reading this if you:

a. Are running Cpanel Server (WHM)
b. Using ASL Firewall from
c. Using PureFTPD
d. Passive Mode Enabled
e. Want to get TLS/SSL Working (either forced or optional)

1. Open ASL GUI and add some ports.
Find the setting inside of ASL Configuration > Firewall > FW_INBOUND_TCP_SERVICES.

Add a port range, for example, 40300:40500 as below.


2. Open WHM and define TLS
In cpanel go to Service Configuration > FTP Server Configuration and change TLS Encryption support to either  “Optional” or “Required”.


3. Define passive ports inside of  PureFTPD Configuration
Open SSH and run the following command “pico /etc/pure-ftpd.conf”.

Scroll down to the section called PassivePortRange and add your new ports.

After adding your port range, save the file and restart the ftp service using “/usr/local/cpanel/scripts/restartsrv pureftpd”


4. Test your FTP connection using TLS/SSL
In your ftp client, ensure that passive mode is enabled and TLS/SSL is selected like below.

You should connect no problems.

You “might” be asked to verify the certificate for the server, but simply agree to it and you will be fine.


[solved] – Error reloading bind on ns1: rndc: ‘reload’ failed: failure on cpanel dns only setup

Gosh. The last few days when I update a dns record or my cpanel system adds a dns record to my dns cluster I get the following errors:

Bind reloading on maggie using rndc zone: []
Bind reloading on ns1 using rndc zone: []
Bind reloading on ns1 using rndc
Error reloading bind on ns1: rndc: 'reload' failed: failure

Bind reloading on ns3 using rndc zone: []
Bind reloading on ns3 using rndc
Error reloading bind on ns3: rndc: 'reload' failed: failure

Bind reloading on ns4 using rndc zone: []
Bind reloading on ns4 using rndc
Error reloading bind on ns4: rndc: 'reload' failed: failure

Bind reloading on ns2 using rndc zone: []
Bind reloading on ns2 using rndc: rndc: 'reload' failed: failure
Error reloading bind on ns2: rndc: 'reload' failed: failure

To cut a long story short I will tell you the direct cause of the issue and the quick steps to resolve it as I looked everywhere for a solution and spent days asking around if anyone else had the same issue.

My dns cluster consists of 4 x Cpanel DNS ONLY servers so I logged into ns1 and ran this command: /etc/init.d/named restart. This gave me the following error in ssh:

Error in named configuration:
/etc/named.conf:10693: zone '': already exists previous definition: /etc/named.conf:8581
/etc/named.conf:23122: zone '': already exists previous definition: /etc/named.conf:21010

AH HA! Looks like there was a duplicate record in the /etc/named.conf

I opened up /etc/named.conf on ns1 and commented out the duplicate entry like so.


Then I went back to the main cpanel server and tried to update a dns record and did not get any errors which was a good sign!

I then did the same with ns2 + ns3 + ns4 and everything was back to normal again.

I do not know what caused this duplication issue but the above solution worked for me and I hope it saves someone else hours of troubleshooting.

[solved] wordpress page showing 404 due to folder permissions

A couple of weeks ago I spent half a day putting in a newsletter sign up function in four languages onto a clients site linked into the api. On the test server it was working perfect. Opt-in email was arriving and script was executing as it should. I was very happy.

However, after the client decided that it was to be put on the live site, I tested the scripts on the live site and was getting a 404 not found error when executing the sign up function.

It was a bit baffling and I then spent a few  hours trying to figure out why it was working fine on the test server and not on the live server.

After many hours of checking scripts, paths, discussing it with fellow coders who were as baffled as I was, in the end, I logged into the clients live server with SSH to see if the server logs would show anything.

It did and this is how I solved the issue:

1. Ran this command as root in SSH: tail -f /usr/local/apache/logs/error_log
2. Went to the live site and pressed submit for the newseltter function to replicate the issue
3. checked in the ssh window and saw the error below.

[Thu Mar 21 15:05:01 2013] [error] [client] SoftException in Application.cpp:601: Directory "/home/siteowner/public_html/" is writeable by group, referer:

AHA!!! The bit that immediately caught my attention was “is writeable by group” as this means that the server is refusing to execute the script because the wordpress theme directory has world writeable permissions (tut tut whoever was developing before me because its pretty bad to have permissions set like that)

4. Seeing this, I then ran a permissions fix across the clients home directory fixing everything to 644 for files and and 755 for folders.
5. Went back and tested my form and it worked perfect.

So, in conclusion, I would not have been able to solve this without root access to the clients server and my advice to anyone else who has the same issue, is to check folder permissions first and in the case you cant find anything, then ask the server admin to check the apache error logs for you.

Hope this helps someone.

[SOLVED] php + mssql + unicode encoding issues

I have a client who has a mobile web application in 52 languages and recently we moved them to a shiny new cpanel web server and suddenly the encoding broke, resulting in any non english characters displaying as ?? and diamonds with question marks in them.

AGGGHHHH!!!! Client is flipping out and we are mystified so we spent pretty much all day on thursday and all day on friday trying to figure it out.

Nothing seemed to work despite trying everything…….

Yes – the charset was set to <meta charset=”utf-8″ />
Yes – the mobile application is set to html5
Yes – the master php.ini file was set to AddDefaultCharset UTF-8
Yes – we included AddDefaultCharset UTF-8 in htaccess file
Yes – the server httpd.conf file included AddDefaultCharset UTF-8
Yes – we tried adding ini_set(‘mssql.charset’, ‘utf-8’); to the application
Yes – we are storing the source data in mssql ntext format
Yes – we tried html_entity_decode($TheText, ENT_QUOTES , “utf-8”);
Yes – we tried iconv(“utf-8”, “utf-8//IGNORE”, $TheText);
Yes – we tried iconv(‘utf-8’, ‘ASCII//TRANSLIT’, $TheText);
Yes – we tried setlocale(LC_CTYPE, ‘tr_TR’);
yes – we tried iconv(‘utf-8′,’iso-8859-2’,$TheText);
Yes –  we tried ini_set(‘mssql.charset’, ‘cp1252’);
Yes – I had the data centre senior admin check the issue (no luck from him)

What worked in the end?

So early on sunday morning I got up fresh and started to look around for more clues as to a solution and literally within a few minutes I found the link: and noticed someone made a comment saying:

“I had the same problem and ini_set('mssql.charset', 'utf-8'); did not work for me. However, it worked in uppercase”.

So I added ini_set(‘mssql.charset’, ‘UTF-8’); to the config file in the mobile application and everything started working perfectly again!

DOH! Something so simple.

[solved] .htaccess not working in wordpress sub directory

Today, one of my clients mentioned that his rest api was not working and was returning 404 errors and the iphone app was broken due to the 404 errors.

As he is running wordpress the immediate thought was that wordpress was overriding something and showing 404 errors inside his api directory (usually 404 errors indicate that the folder/file does not exist but we checked and the folder was there).

Here is a visual example of the issue.

When i opened up his .htaccess file in his /api/ directory I could see the following which is pretty standard .htaccess format.



I noticed that the rewrite base was not being defined and this usually occurs when you have an apache server configured for “AllowOverride None” so I added another line to his .htaccess file to get it working again (see line 4 below RewriteBase /api/).



I hope this helps those who also had this issue.

[SOLVED] Too many authentication failures using Transmit and SFTP

Yesterday and today, I was trying to connect to a new clients server using SFTP with my mac FTP software Transmit on my mac book pro which is running Mountain Lion.

I opened Transmit, entered my new sftp details given to me by the server manager, and received the error below, which I have never ever seen before.

So I checked with the clients server manager and he confirmed he was able to connect from his pc to the server with my credentials no problems. So of course I checked, double checked to make sure I was entering the correct login details and confirmed that my ip was not blocked or anything like that.

Then I tried the same login details on a windows machine on a different network and my other mac. They were connecting just fine so in the end I figured that it must be something on my own mac that causing the connection problem.

So, then I opened up “console” (Applications > Utilities) to see what it was logging and when I was trying to connect with sftp through transmit, console logging was giving me the error “Received disconnect from <remote_server> 2: Too many authentication failures for <user_name>.

This message kind of makes it looks like its the server is kicking me out. But its not the remote server, in the end I have figured out that its in fact the ssh identities on my mac.

The fastest remedy for this was to simply flush all the ssh identities on my mac using the command below in terminal (Applications > Utilities)

ssh-add -D

After doing that, I was then able to connect Transmit using sftp (without key authentication).

So thanks to the following pages for helping me identify the issue and a remedy.

Fixing the Heroku “Too many authentication failures for git” problem
SSH returns “too many authentication failures” error – HostGator

Connect 32 bit Classic ASP Page on 64 bit Windows Server to Remote MYSQL Database

In my company, for our windows machines, we have started to ditch 32 bit OS in favour of 64 bit systems, purely because 64 bit is more scaleable in terms of RAM and CPU for the hungry .asp and .net sites.

One issue I came across today was a customer asking how he can connect his classic asp pages to a remote mysql database.

Despite the server being 64 bit Windows 2008 R2 his site is running in 32 bit mode so we needed to install 32 bit drivers.

So here is what I did and it worked great.

1. installed the 32 bit version of the  mysql odbc connector from
2. in windows explorer, navigated to the syswow64 folder at c:/windows/syswow64/ (this is where all the 32 bit applications are installed)
3. scrolled down to odbcad32.exe and executed it
4. the 32 bit odbc manager popped up and I set up the connection as a dsn

I then created a test classic asp page on the server using dsn connection and it connected without any fuss.

The confusion I had initially was I was trying to configure the 32 bit connection via the 64 bit odbc manager, it was just not working at all, its only when I set the dsn up via the 32 bit odbc manager, everything purred perfectly.

Stop and Disable Mailman on Cpanel

One of our shared servers was showing several thousand bounce messages in the mail queue all generated via a mailman user. So we decided to kill mailman permanently.

However the recomended tweak of switching off Main >> Server Configuration >> Tweak Settings >> Mailman was not working. Still in the background there were mailman processes running, causing havoc.

So I needed to STOP mailman running as well as DISABLE it.

The solution I found was:

1. Run the following command in SSH which will stop the mailman process from running.

2. Create an .htaccess for mailman – Create a file at in the following location on your server.

3. Put the following code into the file, this will give a permission denied error on the mailman system.

4. Finally, add the .htaccess to the exclude file so cPanel won’t remove / change it. Run the following in SSH.

Bang! There you go. No more issues with mailman. Load dropped like a stone. Sweet!