Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author tbenyon

    (@tbenyon)

    Hi Mike,

    Sounds like a cock up my end.

    I forgot to cater for WP installed in sub-directories.

    I’ll start looking at this on my lunch break today and will keep you posted.

    If you haven’t had an update from me by tomorrow evening, feel free to chase me ??

    Thanks for the detailed explanation and apologies for not getting this right first time round!

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Hi Mike,

    Had a look at this today and I’ve fixed it on my local copy.

    I’m just doing tweaks to the error message you should have gotten.

    However, the issue was isolated to the test button so the actual integration should work.

    As always, backup your db before testing.

    I’ll send another message once I’ve got it deployed. Won’t be home till late tonight and daughter is sick so you may have to wait till tomorrow.

    If it makes a big difference to get this out in the next few later tonight (UK time) let me know and I’ll stay up and get it done.

    Thanks,

    Tom

    Thread Starter MikeColes

    (@mikecoles)

    Thanks heaps Tom,
    If I can get it this week, that will be perfect. I’m in Sydney Australia, so we’re upside down in time from each other.

    Mike

    Hello, i have the same issue with your plugins, i really apreciate your help, thanks a lot

    Plugin Author tbenyon

    (@tbenyon)

    Hey @mikecoles and @roger23e,

    Could you download the latest update and see if it fixes your issue.

    If it does PLEASE write a 5 star review! ??

    If not get straight back to me with what you’re seeing and I’ll have another go!

    Thanks for the support!

    Tom

    Thread Starter MikeColes

    (@mikecoles)

    So I deleted the plugin and downloaded the new version. When I press test, I get: ERROR: 999 in the div marked “exlog_test_results_inner_container”

    I am still getting the load script error: Failed to load resource: the server responded with a status of 404 ()

    And it is looking for:
    https://mywebsite/wp-admin/admin-ajax.php?action=exlog_test_connection&test_results=10

    Whereas it should be going to:
    https://mywebsite/portal/blog/wp-admin/admin-ajax.php?action=exlog_test_connection&test_results=10

    Sorry Tom, we’re so close. Can you take a look? Is this something I’m doing wrong?

    Plugin Author tbenyon

    (@tbenyon)

    Hey Mike,

    Really sorry.

    Can you please check something for me?

    Could you please check the options page container with the class “exlog_options_page”. It should have a data attribute called “data-exlog-wp-base” which should store your site url.

    I would expect it to be “https://mywebsite/portal/blog“.

    The JS should be using that as the base for the request.

    If it is there, the front end JS isn’t grabbing that correctly or not using it correctly.

    If it is not there I know there is a PHO issue.

    Thanks,

    Tom

    Thread Starter MikeColes

    (@mikecoles)

    I can see:

    <ul
    class=”exlog_options_page”
    data-exlog-wp-base=”https://mywebsite/portal/blog&#8221;
    >

    when I search for the class “exlog_options_page”

    Plugin Author tbenyon

    (@tbenyon)

    Thanks for the quick response.

    Are you getting any errrors in the console?

    Thread Starter MikeColes

    (@mikecoles)

    Before I test I get:
    Failed to load resource: the server responded with a status of 404 ()
    on
    https://mywebsite/wp-admin/admin-ajax.php?action=exlog_test_connection&test_results=10

    Is that what you mean?

    Thread Starter MikeColes

    (@mikecoles)

    Happy to share my screen with you, so you can see what I’m seeing…

    Thread Starter MikeColes

    (@mikecoles)

    Don’t know what you did, but it is working…

    Tests okay.

    Returns good data.

    Thank you for your persistence. Much appreciated.

    Plugin Author tbenyon

    (@tbenyon)

    I would LOVE to do that but I’ve been told off before for this by the moderation team.

    Although you hypothetically could find me on FB or Linked In I can’t share contact information on here or gain access to your system due to security issues. Which makes sense as it would mean developers potentially getting access to peoples live systems – potentially with malicious intent.

    Are you running this site locally or on a server? Are you comfortable modifying some code for me to add more logging to the local JS?

    The file that is doing this check is here:
    /wp-content/plugins/external-login/js/exlog_test.js

    Could you swap the code to:

    
    (function ($) {
        $(function () {
            var $modal = $(".exlog_modal");
            var $loader = $(".exlog_loader_container");
            var $modal_content_container = $(".exlog_test_results_inner_container", $modal);
            var $modal_test_results = $(".exlog_test_results", $modal);
            var $modal_error = $(".exlog_test_fail", $modal_content_container);
            var $modal_error_title = $(".exlog-error-title", $modal_error);
            var $modal_error_message = $(".exlog-error-message", $modal_error);
            var $wordpressBaseUrlContainer = $('[data-exlog-wp-base]');
            var wordpressBaseUrl = $wordpressBaseUrlContainer.attr('data-exlog-wp-base');
    
          console.log("EXLOG - Base container length: ", $wordpressBaseUrlContainer.length);
          console.log("EXLOG - Base container URL: ", wordpressBaseUrl);
    
          var error_messages = {
                unknown: {
                    title: "Error",
                    message: "This is an unknown error."
                },
                lost: {
                  title: "Error",
                  message: "Could not access the server to run the test."
                },
                server: {
                    title: "Error",
                    message: "There was an error on the server."
                },
                empty_result: {
                  title: "Error",
                  message: "No data returned from the server. Please check your settings."
                }
            };
    
            var error_codes = {
              100: error_messages.unknown,       // Ajax returned, unknown error
              101: error_messages.unknown,       // Unknown error passed to error handler
              404: error_messages.lost,          // 404 from Ajax
              500: error_messages.server,        // 500 from server - see test_results.php?
              501: error_messages.server,        // String of "0" returned - caused by missing function?
              502: error_messages.server,        // 500ish error from Ajax
              600: error_messages.empty_result,  // Empty AJAX response
              601: error_messages.empty_result   // Blank string AJAX response
    //        999: ????????????????????????      // Hard coded in markup case this system fails
            };
    
            function errorMessageState(error_code) {
              console.log("EXLOG - Error message state ran");
              console.log("EXLOG - Error code: ", error_code);
    
              if (!error_code) {
                $modal_error.hide();
              }
    
              if (!error_codes.hasOwnProperty(error_code)) {
                error_code = 101;
              }
    
              console.log("EXLOG - Error code validated: ", error_code);
              var error_data = error_codes[error_code];
    
              console.log("EXLOG - All error codes: ", error_codes);
              console.log("EXLOG - Error data: ", error_data);
    
              console.log("EXLOG - Error title length: ", $modal_error_title.length);
              console.log("EXLOG - Error message length :", $modal_error_message.length);
    
              $modal_error_title.text(error_data.title + ": " + error_code);
              $modal_error_message.text(error_data.message);
    
              $modal_error.show();
            }
    
            $(".exlog_close_button", $modal).click(function () {
                $modal_error.hide();
                $modal.hide();
                $modal_test_results.text("");
            });
    
            $("input.exlog_test_connection").click(function () {
                $modal.show();
                $loader.show();
                var data = {
                    'action': 'exlog_test_connection',
                    'test_results': 10
                };
    
              console.log("EXLOG - Error AJAX about to run.");
              console.log("EXLOG - Base URL = ", wordpressBaseUrl);
              console.log("EXLOG - Whole URL = ", wordpressBaseUrl + "/wp-admin/admin-ajax.php");
    
              $.ajax({
                    type: "GET",
                    url: wordpressBaseUrl + "/wp-admin/admin-ajax.php",
                    data: data,
                    success: function (data) {
                        if (!data) {
                          errorMessageState(600);
                          $modal_error.show();
                        } else if (data == "") {
                          errorMessageState(601);
                          $modal_error.show();
                        } else if (data === "0") {
                          errorMessageState(501);
                          $modal_error.show();
                        } else {
                          $modal_error.hide();
                          $modal_test_results.append(data);
                        }
                        $loader.hide();
                    },
                    error: function (xhr, ajaxOptions, thrownError){
                      if(xhr.status == 404) {
                        errorMessageState(404);
                      } else if (xhr.status === 500) {
                        errorMessageState(500);
                      } else if (Math.floor(xhr.status / 100) === 5) {
                        errorMessageState(502);
                      } else {
                        errorMessageState(100);
                      }
                      $loader.hide();
                    }
                });
            });
        });
    }(jQuery));
    
    

    I would then be interested to see what console logs you now get.

    Thanks,

    Tom

    Plugin Author tbenyon

    (@tbenyon)

    Oh sorry just seen your message, haven’t changed a thing. Maybe your JS was cached.

    Apologies for it not working first time!

    Could you please write me a review, I’d be really grateful ??

    Thanks,

    Tom

    Thread Starter MikeColes

    (@mikecoles)

    Yes, I’ll happily write the review and I’ve followed the connection to buy you a (couple of) pints of beer…

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘DB Connection Issue when WP in sub folder’ is closed to new replies.