Fix for duplicated domain name
I've solved the problem with a hack but include it here in case anyone else encounters this problem.
The duplicated domain name was caused by cPanel with the full path being shown because of a shared SSL. To fix it I used substr() on $_SERVER["PHP_SELF"] to remove the extra domain.
I also had to edit helper_php.php which is not ideal but got me out of a corner.