WordPress.org

Ready to get started?Download WordPress

Forums

WHMCS Bridge
[RESOLVED] WHMCS bridge URLs double up, URLs broken (3 posts)

  1. nightkid
    Member
    Posted 11 months ago #

    I actually fixed mine, posting this for people who are experiencing the same problem. i-plugins, you don't have any contact forms for a bug report, it's a shame :) Great job on the plugin anyway!

    Symptom:

    wordpress at http://mydomain.com/
    whmcs at https://mydomain.com/billing/ (or any other subdir)
    whmcs-bridge page at http://mydomain.com/client/ , configured to use the above whmcs URL.

    With plain HTTP, the plugin works fine, and links are generated like http://mydomain.com/client/?ccce=cart .

    When you try HTTPS though, it gets ugly: load https://mydomain.com/client/ , and all links inside it turn into https://domain.comhttps//domain.com/client/?ccce=cart . Many people reported this behavior, but everyone failed to notice that it only happens when your SSL mode is different from what you have in WordPress general settings, it either works in http or https - works when it matches your wordpress site name, fails otherwise.

    The bug is in the plugin's includes/parser.inc.php , reported by drop9 here: http://wordpress.org/support/topic/plugin-whmcs-bridge-error-with-links?replies=2 . It's a sanity check, which looks like it's supposed to eliminate our problem instead of causing it:

    $homePage = get_option('home');
    $wordpressPageName = get_permalink($pageID);
    $wordpressPageName = str_replace($homePage,"",$wordpressPageName);
    $pid="";
    $home=$homePage.$wordpressPageName;

    In a nutshell, this is supposed to remove the occurrences of $homePage from $wordpressPageName to avoid duplication. I don't know why they concatenate these two strings, but i'm no developer, maybe there's a valid reason for that ugly hack.

    Anyway, here's what happened to the variables in my case:

    $homePage: http://domain.com
    $wordpressPageName: https://domain.com/client/

    See? the string "https://domain.com/client/" does not contain the string "http://domain.com" , so str_replace failed to clean it up.

    $homePage here is the variable from WordPress main settings page, and $wordpressPageName is taken from the URL we are currently visiting.

    One solution would be to change the general WordPress setting from http://domain.com to https://domain.com , but this will obviously turn your entire website HTTPS. I made a hack instead (i copied the developers' hack used for another variable just a few lines lower):

    $homePage = get_option('home');
    if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == "on")) {
     $homePage=str_replace('http://','https://',$homePage);
    }

    No harm done because, like i said, the same hack is used elsewhere in the same script.

    There is also a WordPress SSL module, and i-plugins mentioned that you could install it to get this fixed, but i don't see a reason to bother.

    Works like in charm in both HTTP and HTTPS.

    Hope that helps someone!

    Regards, Nick

    https://wordpress.org/plugins/whmcs-bridge/

  2. Fox Jones Web Design
    Member
    Posted 10 months ago #

    Nick, thanks for the write-up. I'm having the same issue, but I'm not sure I understand how to apply this fix. I tried editing parser.inc.php to no avail, where do I make the change?

    - fox

  3. Fox Jones Web Design
    Member
    Posted 10 months ago #

    oh, nevermind. i figured it out. thanks Nick! very helpful.

Reply

You must log in to post.

About this Plugin

About this Topic